-
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
Add analyzer action for reporting diagnostics in additional files #45076
Conversation
@dotnet/roslyn-compiler Ping for reviews. |
Addresses dotnet#44131 The added analyzer APIs are similar to the existing APIs for syntax tree callback. This commit adds the compiler APIs + tests Future enhancement: Add analyzer action for reporting diagnostics in analyzer config files
09f2fb4
to
d2d197f
Compare
Ping @dotnet/roslyn-compiler for reviews |
Ping @dotnet/roslyn-compiler @dotnet/roslyn-ide for reviews. |
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalysisContextInfo.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalysisContextInfo.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalysisResultBuilder.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalysisScope.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalysisScope.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalysisScope.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalysisScope.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalysisContextInfo.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalysisResult.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalysisResultBuilder.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.NormalPriorityProcessor.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.NormalPriorityProcessor.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.NormalPriorityProcessor.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/SolutionCrawler/AggregateIncrementalAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/SolutionCrawler/AggregateIncrementalAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/SolutionCrawler/AggregateIncrementalAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/SolutionCrawler/AggregateIncrementalAnalyzer.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, just a few nits. Would like to understand the plan for partners moving to the new interface / combining the interfaces
Thank you everyone! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto-approval
For reasons that aren't entirely clear, when we create a preview of a code fix, we remove and re-add documents that are being changed when we produce the PreviewWorkspace. This process had an bug which meant that the file path of an .editorconfig got dropped, so the resultant .editorconfig document path was null. This later caused a crash if the diagnostic engine, when processing the PreviewWorkspace's new solution, tried asking for a Compilation, since the null path would get passed to AnalyzerConfig.Parse(), and it would throw. This was exposed by dotnet#45076; until then if you had a preview of just an .editorconfig file, nothing would actually be analyzed and so nothing asked for the Compilation. The crash is "fixed" by dotnet#44331 in that asking for a Compilation no longer results in a call to AnalyzerConfig.Parse(); you have to ask for a Compilation and then do something with a semantic model. By luck, that doesn't happen in the common repro, but more obscure things absolutely could still fail. This is being tested by the integration test being added in dotnet#46639. We don't really have a good unit tests here as far as I can tell, but even then a unit test really doesn't validate any of the end-to-end here. Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1162464
Closes dotnet#44131 dotnet#45076 added support for reporting analyzer diagnostics in additional files. This PR addresses pending work from dotnet#44131 (comment) by adding similar support for editorconfig/globalconfig files in the project. There are two primary public API additions
Addresses #44131
The added analyzer APIs are similar to the existing APIs for syntax tree callback.
I have split the changes into separate commits for compiler and IDE changes for easier review.
Compiler changes in 450cf6a: Adds analyzer API + driver implementation + tests.
IDE changes in d2d197f: IDE support for analyzing and reporting diagnostics in non-source files
Future enhancement: Add analyzer action for reporting diagnostics in analyzer config files.