Omnisharp-roslyn: Code fixes with additional files not working

Created on 24 Aug 2019  路  5Comments  路  Source: OmniSharp/omnisharp-roslyn

It looks like code fixes from a roslyn analyzer aren't actually being applied.

Minimal repro project: Archive.zip. Open in VS Code with analyzers enabled ("omnisharp.enableRoslynAnalyzers": true)

This project is using Roslyn's PublicAPI analyzer. Among other things, it adds some custom code fixes to the quick-fix drop down. This is populating correctly in the UI.

But, when I execute the code fixes, nothing happens.

image

The log (log.txt) shows

[info]: OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.RunCodeActionService
        Applying code action: Add Class1 to public API

This should have made a change to the PublicAPI.Unshipped.txt file, but it didn't.
image

This code fix works correctly in Visual Studio 2019.

Details

_Omnisharp version_: 1.34.3-beta.22
_VS Code_: 1.37.1
_C# extension_: 1.21.1
_OS_: macOS Mojave
_Mono_: 5.18.1
_dotnet_: 2.2.105

bug

Most helpful comment

Thanks for the report and the repro.

The problem here is two-fold:
a) OmniSharp doesn't apply changes to additional documents (non core source documents) when running code actions.
b) changes to additional documents are not reflected in Workspace state, which means even when a) is handled, an invoked code fix which modifies the API surface document wouldn't be picked up by analyzer engine and the diagnostic wouldn't go away

Both seem reasonably easy to fix, I think - in fact I put together a quick PoC on my machine and it seems to work fine. I will PR this in the coming days.

Thanks again for reporting.

All 5 comments

Thanks for the report and the repro.

The problem here is two-fold:
a) OmniSharp doesn't apply changes to additional documents (non core source documents) when running code actions.
b) changes to additional documents are not reflected in Workspace state, which means even when a) is handled, an invoked code fix which modifies the API surface document wouldn't be picked up by analyzer engine and the diagnostic wouldn't go away

Both seem reasonably easy to fix, I think - in fact I put together a quick PoC on my machine and it seems to work fine. I will PR this in the coming days.

Thanks again for reporting.

Any update on this? Still having the same issue today. Thanks!

The branch is here https://github.com/OmniSharp/omnisharp-roslyn/tree/feature/respect-additional-files
it has to be updated to latest master, and we need to add some tests.

It hasn't been the highest priority to be honest due to other work.

any update on this? my entire dept is suffering a lack of ability to generate api documentation in an automated fashion without using a windows machine and visual studio IDE as we've switched to Macs for developers

no update

Was this page helpful?
0 / 5 - 0 ratings