QUESTION: How do I apply my personal DocumentationProvider to source tree symbols? Which is the type of symbol i get when i use the SymbolFinder.FindSymbolAtPosition()
Specifically I want to override the GetDocumentationForSymbol() function. I have it overridden for my autocomplete symbols but not the symbols i get from hover over.
BACKGROUND:
Hi, I am using roslyn to gather intellisense for a text editor i am creating. One of the things i need to make is quick info or tool tips. I have it working for the autocomplete suggestions. by using a snippet that looks like this
compilation = CSharpCompilation.Create(
"MyIntellisense",
new[] { CSharpSyntaxTree.ParseText(dotNetCode) },
assemblies
.Select(i => MetadataReference
.CreateFromFile(i.Location, MetadataReferenceProperties.Assembly,
new DotNetDocumentationProvider(
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
this uses my own personal DotNetDocumentationProvider which parses XML and documentation the way I need it. This works for assembly symbols which are the types of symbols I have when i use Recommender.GetRecommendedSymbolsAtPosition().
EDIT: Just wanted to give more background :)
I get symbols in two different ways.
1) One way is when I call
var symbols = Recommender.GetRecommendedSymbolsAtPosition(semanticModel, offset, solution.Workspace);
I use this when the user asks for auto-complete information With these symbols I can go through and for each one call:
var information = symbol.GetDocumentationCommentXml();
This eventually calls a function I have overridden from the class DocumentationProvider :
protected override string GetDocumentationForSymbol(string documentationMemberID, CultureInfo preferredCulture, CancellationToken cancellationToken = default(CancellationToken))
2) The second way is for when the user hovers over
var symbol = SymbolFinder.FindSymbolAtPosition(semanticModel, offset, workspace, cancellationToken);
I call the exact same function (from the same line of code actually, keeping it DRY)
var information = symbol.GetDocumentationCommentXml();
But this does not invoke my overridden GetDocumentationCommentXml() instead the default Roslyn one is called.
Thanks!
Not finding all of the symbols I need,How to find more symbols using the Roslyn API
Another question I asked, when I solved this issue it then solved the problem i was having here. The problem was that i thought
_workspace.CurrentSolution.AddMetadataReferences(_currentProject.Id,_compilation.References);
updated the workspace i was working in. but it does not it returns a solution with the references added. i needed to use
_workspace.TryApplyChanges(referenceSolution);
to save it. Thanks to Jason for answering my other question found at the link. If you post here i will mark it as an answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With