I've written a simple C# code generator that implements Microsoft.CodeAnalysis.ISourceGenerator that inspects an enum declaration and generates code based on members that are decorated with certain attributes. It is working as expected except that I cannot retrieve—in the ISyntaxContextReceiver that I register—any XML documentation comments.
I've tried the solution found in this SO post, but whether I inspect the leading trivia on the enum constant's syntax model or call GetDocumentationCommentXml() on the enum constant's semantic model, there's never any XML documentation. (The former technique always yields a trivia collection with a single WhitespaceTrivia item; the latter always returns an empty string.)
I suspect that this is because the GeneratorExecutionContext passed to the generator's Execute method has ParseOptions.DocumentationMode set to DocumentationMode.None, but I can't find any way to change ParseOptions. Does anyone know how this can be done or what else might enable retrieval of XML documentation nodes?
<GenerateDocumentationFile>true</GenerateDocumentationFile>property in csproj. This controls whether the compiler parses the documentation comments or not.