I've started working on creating some custom analyzers for the first time, but haven't been able to find any guidelines as to when ICodeBlockEndedAnalyzer and ICompilationEndedAnalyzer should be implemented, rather than their ICodeBlockStartedAnalyzer
or ICompilationStartedAnalyzer counterparts.
Looking through the Roslyn solution, there are 4 instances of ICodeBlockEndedAnalyzer being implemented:
- CA1024DiagnosticAnalyzer.CA1024CodeBlockEndedAnalyzer, which has a trivial OnCodeBlockEnded method
- CA1821DiagnosticAnalyzer.AbstractCodeBlockEndedAnalyzer, which has a simple OnCodeBlockEnded method
- CA2214DiagnosticAnalyzer.AbstractSyntaxNodeAnalyzer, which has an empty OnCodeBlockEnded method
- SpecializedEnumerableCreationAnalyzer.AbstractSyntaxAnalyzer, which has an empty OnCodeBlockEnded method
And there is only instance of an ICompilationEndedAnalyzer implementation with a non-empty OnCompilationEnded method:
- CA2213DiagnosticAnalyzer.AbstractAnalyzer, which has a simple OnCompilationEnded method
None of those implementations seem computationally-intensive, so I'm not sure what the use cases of the I*EndedAnalyzer interfaces are. It seems like all analysis could just be done in the I*StartedAnalyzer implementations. Are there any guidelines or documentation
as to how the I*StartedAnalyzer and I*EndedAnalyzer interfaces should be used?