Open chucker opened 5 months ago
AnalyzeAdditionalFile seems to only ever get logged when explicitly building the project.
@sharwell I think this is expected behavior, could you pls confirm?
what's the guidance on running an analyzer on a non-C# file (in my case, a .cshtml, but .xaml and others would be of use as well) as the users view/edit code?
@davidwengier Any suggestions here?
I don't think this will work right now, in the IDE at least. Roslyn doesn't register for diagnostic requests for additional files at the moment, and Razor won't run Roslyn diagnostics. I expect this to change in future with our cohosting effort, but that doesn't help now. Depending on the type of analysis being performed, analyzing and reporting diagnostics on the generated C# file that is compiled for a .cshtml should work fine, and Razor tooling will translate diagnostics reported in those files, to the appropriate position in the .cshtml file itself.
Version Used: C# Tools 4.10.0-3.24211.4+e482b6e
Steps to Reproduce:
context.RegisterAdditionalFileAction
yetDiagnosticAnalyzer
, like so:<AdditionalFiles>
includes a file, or a file is implicitly in it for another reason.Diagnostic Id:
n/a
Expected Behavior:
AnalyzeAdditionalFile
should be logged on occasion when such a file is frontmost, and being edited. I.e., the analyzer should be usable during design time.Actual Behavior:
AnalyzeAdditionalFile
seems to only ever get logged when explicitly building the project.I'm unsure if this is by design. (The docs don't seem to imply as much.) It's not the behavior I observe with
RegisterSymbolAction
, where I can simply make a C# file frontmost, and the analyzer will run. If it is by design thatRegisterAdditionalFileAction
only takes place at build, what's the guidance on running an analyzer on a non-C# file (in my case, a.cshtml
, but.xaml
and others would be of use as well) as the users view/edit code?