If an analyzer registers both an OperationAction and an OperationBlockStartAction on the same context, the block start action is never getting invoked in IDE analyzer execution.
For example, consider the below analyzer:
[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]
public sealed class RegisterOperationBlockAndOperationActionAnalyzer : DiagnosticAnalyzer
{
private static readonly DiagnosticDescriptor s_descriptor = new DiagnosticDescriptor(
"ID0001",
"Title",
"Message",
"Category",
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(s_descriptor);
public override void Initialize(AnalysisContext analysisContext)
{
analysisContext.RegisterOperationAction(_ => { }, OperationKind.Invocation);
analysisContext.RegisterOperationBlockStartAction(OnOperationBlockStart);
}
private void OnOperationBlockStart(OperationBlockStartAnalysisContext context)
{
context.RegisterOperationBlockEndAction(
endContext => endContext.ReportDiagnostic(Diagnostic.Create(s_descriptor, context.OwningSymbol.Locations[0])));
}
}
This analyzer never gets the OperationBlockStartAction callback when executed in the IDE, but it works fine in command line case.
If an analyzer registers both an OperationAction and an OperationBlockStartAction on the same context, the block start action is never getting invoked in IDE analyzer execution.
For example, consider the below analyzer:
This analyzer never gets the OperationBlockStartAction callback when executed in the IDE, but it works fine in command line case.