Skip to content
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

Xml documentation is missing for imported symbols in Roslyn Projects #246

Closed
vladimirKa002 opened this issue Jan 31, 2024 · 3 comments
Closed
Labels
Discussion/Question Discussions or questions about the code

Comments

@vladimirKa002
Copy link

Hello. I need to extract Xml documentation from all ISymbols. For this, I run this code to create a Roslyn Project and start its analysis:

AnalyzerManager manager = new AnalyzerManager();
IProjectAnalyzer analyzer = manager.GetProject(projectPath);
AdhocWorkspace workspace = new AdhocWorkspace();
Project project = analyzer.AddToWorkspace(workspace);

Compilation compilation = project.GetCompilationAsync().Result;

// ... For each document in project.Documents
var syntaxTree = document.GetSyntaxTreeAsync().Result;
var semanticModel = compilation.GetSemanticModel(syntaxTree, true);

// ... Get some symbol from syntaxtree using semanticmodel and extract Xml
var xml = symbol.GetDocumentationCommentXml(expandIncludes: true);

I can normally obtain Xml documentation for symbols declared inside the project.

However, no documentation is available for symbols loaded from imported packages. For example, if my analyser meets List symbol, it does not have Xml comment despite it is imported properly in analysed code.

Could you please advise do I miss anything in my code or maybe my Project loading stage is wrong?

@Corniel
Copy link
Contributor

Corniel commented Feb 5, 2024

So, If I understand you correctly, you receive the XML-comments from your own code, but not from referenced code?

@vladimirKa002
Copy link
Author

I am able to receive Xml-comments from the project's code itself. For example, if I run analysis of some project, the documentation of its classes and methods will be loaded normally. However, this project also uses some classes from referenced packages, for example, List class - its Xml documentation is missing.

@phmonte
Copy link
Owner

phmonte commented Feb 18, 2024

Hello @vladimirKa002, I believe I understand what you mean, I was curious and did some local tests, I really didn't find a way that works.
Looking at swashbuckle it seems to me (I'm not sure) that it works because it reads the XML file from the repository, it would be an alternative to a "controlled" external reference where you have access to the XML, but you would have to code something to do this.
I found this discussion that seems to be the same topic we are talking about here.

@phmonte phmonte added the Discussion/Question Discussions or questions about the code label Feb 18, 2024
@phmonte phmonte closed this as completed Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion/Question Discussions or questions about the code
Projects
None yet
Development

No branches or pull requests

3 participants