-
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
Unable to fetch XML Documentation from symbol a member of a custom Assembly that has a XML documentation file. #23673
Comments
I personally feel XmlDocumentationProvider is very much valid for custom analyzers, with which you can provide XML documentation even for symbols from a custom assembly referenced. i.e. by making API ISymbol.GetDocumentationCommentXml() valid even for custom assemblies which provides XML Documentation externally. |
I agree with this. |
This is going to block the ability to implement analyzers like DotNetAnalyzers/DocumentationAnalyzers#16. |
I don't think XML documentation is loaded by the compiler for metadata references. If I'm right, this would be a feature request to start loading them. Marking as Investigation Required to determine the scope of the work needed to satisfy this request. |
@gafter For the analyzer testing library, we use the following code to construct a It will likely be simpler in current versions of Roslyn and/or in the compiler, since reflection would not be necessary to access these types/methods. |
Could someone explain to me what a "metadata reference" is? Basically I can't figure out if what I'm trying to do is supported or not, and if not, if it falls into the same category as this feature request. If my scenario is different, I'm happy to open a new issue. My scenario is as follows:
Whenever I attempt to get the XMLDocs from an ISymbol in AssemblyA, it returns an empty string. I was surprised, because I thought that xmldocs should be returned if the compiler has access to the source code (I wouldn't necessarily expect xml docs to be available if I reference a dll instead of a csproj). |
@lukewis your scenario is the same scenario as this issue |
Hi Sam @sharwell, Are you able to give us any help on resolving or working around this? I have the same issue with a source generator that is added (as a ProjectReference) to ProjectA , but is trying to read the XML documentation of a We have: But the source generator always returns If there is a way to explicitly add the |
@jezzsantos I'm not aware of any workarounds for this currently. XML documentation comments are not available for symbols defined in metadata during command line compilation scenarios, which includes both analyzers and source generators.
Syntax is not available for symbols defined outside the current project (including cases where the symbol is defined in a different project in the same solution). |
Thanks @sharwell. Understood. Have found an alternative approach with custom OperationFilters |
Version Used:
Visul Studio 2017 v15.5
Roslyn v2.3.0
.Net Standard v1.3
Steps to Reproduce:
Analyzer analyses member access syntax node - context.RegisterSyntaxNodeAction(Analyze, SyntaxKind.SimpleMemberAccessExpression).
And then access symbol to retrieve the XML Documentation in the called method symbol.
var symbolDeclarationSyntaxNode = symbol.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax();
var leadingTrivia = symbolDeclarationSyntaxNode.GetLeadingTrivia();
Unable to retrieve syntax using this approach to access leading trivia. It looks like syntax infrormation is not available to the compilation.
How can I get the XML Documentation generated for provider assembly here in consumer compilation?
Do I need to do anything additional to get documentation available through ISymbol.GetDocumentationCommentXml()?
Expected Behavior:
ISymbol.GetDocumentationCommentXml() gives the XML documentation as in the XML DOcumentation file.
Actual Behavior:
ISymbol.GetDocumentationCommentXml() always returns string.Empty.
Please suggest how can I retrieve XML Documentation from the symbol of another assembly with XML Documentation file.
Thanks
Basanth
The text was updated successfully, but these errors were encountered: