-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose workspace level feature APIs as libraries #19908
Comments
This API is heavily designed around the use cases of our two 'implement interface' features. i.e. the one that gets invoked by VB if you hit return after an implements-clause, and the light-bulb we show in VB/C#. It is not a generalized API to say "here is a type, give me that type back with the appropriate interface implemented." We'd need to do a fair amount of work to support that, and once we exposed it we would not be able to change this. So we're not likely to get around to this for a long time FYI. |
@CyrusNajmabadi The primary interface into this code seems to be:
I'm not aware of whether the The first however takes an arbitrary I've skimmed the implementation, it seems to extract the relevant |
But if we then ever want to change that, it would be a breaking change. We have to support these APIs for 10+ years. That takes planning and care to make sure we do it properly. |
Oh wow. Maybe something less official than the Roslyn package itself then? I'm just looking for a way to exploit the work that's gone into all the existing Roslyn analyzers and code-fixes. At a high level, an analyzer is just a function that takes a workspace and produces a list of problems, and a code-fix is a function that takes a workspace and produces a different workspace. It would be great if these could be published and composed at a granular level, similarly to how Babel works. I hear you on the planning and care front, just bringing up an idea. |
@CyrusNajmabadi Also see: dotnet/vscode-csharp#43. If the feature level API is not exposed in some way, all of the analyzers+code-fixes+refactorings you have here will have to be reimplemented in OmniSharp. |
Omnisharp can use our public DiagnosticAnalyzer+CodeActions API for this. There is no need to get at internal implementation details. |
@CyrusNajmabadi Could you point me to the API you're referring to? If it's this, do you mean they should derive from that to implement analyzers? |
Tagging @DustinCampbell on this one - there is a plan to support all the Roslyn code actions in OmniSharp. As for the feature specific request, I could imagine making something public if there was a specific proposal for a public API that we could support as @CyrusNajmabadi mentioned above. |
We're all working together here. 😄 OmniSharp provides Code Fixes and Refactorings today by calling into them directly. Unfortunately, OmniSharp does not have a diagnostic analysis engine, which is something we might expose from Roslyn in the future to allow OmniSharp and other editors to take advantage of. That said, the current experience works well enough for now in VS Code: |
@DustinCampbell Right, so at the code level, how are you calling into Roslyn to populate that dropdown? Additionally, what API are you using to actually apply the fix? Skimming the source, I can see you're doing some kind of reflection magic here: https://github.com/OmniSharp/omnisharp-roslyn/blob/dev/src/OmniSharp.Roslyn.CSharp/CodeActions/CodeActionHelper.cs, but it's hard for me to understand what's going on; the commit messages suggest you're interacting with Roslyn via MEF somehow. |
We're calling directly into the fixes and refactorings to see if they're available. Additionally, we have some reflection code to specifically drill into nested code actions, since this isn't exposed today. This works well for most built-in code actions, but there is no diagnostic analyzer engine for OmniSharp today. So, code fixes that are driven off of custom diagnostics will not work. |
I'm writing a Roslyn code generator and found that I needed the ability to generate a fake implementation of every member in an interface in an arbitrary class/struct. Rather than implement this from scratch, I wanted to reuse the logic already present in the "implement missing interface members" code fix.
Unfortunately, this is not exposed as a public API. At a glance it seems to have a sufficiently internals-agnostic API that it could just be wrapped up into a library and published, so it'd be great if this (and other code-refactorings + analyzers) could be published on NuGet.
The text was updated successfully, but these errors were encountered: