Change Visual Studio suggetions with custom analysers
Hiya.. ohh discords new "forum" channels are super useful for this huh?. anyway.
So I managed to implement a C# proposal https://github.com/dotnet/csharplang/discussions/6394 (that is I implemented it using an analyser extension) for my own use.
there is 1 problem though I can't seem to figure out how I tell visual studios "suggestions" feature (where when you start typing suggestions for member names, type names, etc show up.) what members and types it should and shouldn't suggest. I would have thought that is a common use of analysers and that the extension and or analyser api has some kind of build in method to do it, or atleast I hope(ed). Let me know what I'm missing.
Thanks everyone.
18 Replies
You may want to ask in #roslyn if you don't get help here in the next few hours. It's more focused towards analyzers. Just don't leave both questions up at the same time.
@Metasyntactic, this is a you question
Not sure whether you can remove things from completion, only add them, but Cyrus will know for sure
Thanks Fred
For adding, you'd implement and export a
CompletionProvider
: https://sourceroslyn.io/#Microsoft.CodeAnalysis.Features/Completion/CompletionProvider.cs,3632bba4d25ec249Not sure what I'm being asked
Can you implement anything to remove existing completions from the list? Presumably to remove suggestions that should not be in this partial part from the list
I want to remove specific suggestions from the auto completion list via an analyser.
As I said above I”ve already successfully implemented an analyser that comply with the C# feature proposal, what I need now is to prevent those members from showing up in auto completion too
there is no way to do this.
we do not allow anyone to remove items.
(using roslyn)
there may be a VS mechanism for this
Yeah I figured this would be a VS thing. Do you know if there is any VS people on the discord?
I believe they're generally on gitter, not discord. There's some examples of the SDK and a link to the gitter here: https://github.com/Microsoft/VSSDK-Extensibility-Samples
GitHub
GitHub - microsoft/VSSDK-Extensibility-Samples: Samples for buildin...
Samples for building your own Visual Studio extensions - GitHub - microsoft/VSSDK-Extensibility-Samples: Samples for building your own Visual Studio extensions
Maybe @AdmSnyder can give some insight if a VS extension can remove suggested suggestions from autocompletion. He's made a few VS extensions, so might know.
Would probably be nicer if Roslyn Analyzers would allow you to provide priority hints that VS could act upon.
That's not the problem: they can
The problem is removing hints
Can you not hint that a suggestion should be hidden ("zero" priority)? Or can you only specify "minimum" priority?
I really need to get involved in the tooling side sometime.
It doesn't matter if you aren't the one making the suggestion
i wonder... there are a couple attributes like DebuggersStepThrough, DesignerVisible, ... that tell specific tooling to ignore specific stuff. - maybe one of these should be invented?
maybe an ObsoleteAttribute would already discourage that?
doesn't help with scoped restrictions, though.
nah, never did anything in that area.
Why there is not something like a [EditorHidden] attribute that work within the same project (unlike EditorBrowsable or whatever it is called) is indeed 1 of lives biggest questions huh?
So no ideas about this?
No, sorry
:’(