public override void Initialize(AnalysisContext analysisContext) { analysisContext.RegisterCompilationStartAction( (context) => { var eventHandler = WellKnownTypes.EventHandler(context.Compilation); if (eventHandler == null) { return; } var genericEventHandler = WellKnownTypes.GenericEventHandler(context.Compilation); if (genericEventHandler == null) { return; } var eventArgs = WellKnownTypes.EventArgs(context.Compilation); if (eventArgs == null) { return; } var comSourceInterfacesAttribute = WellKnownTypes.ComSourceInterfaceAttribute(context.Compilation); if (comSourceInterfacesAttribute == null) { return; } context.RegisterSymbolAction(GetAnalyzer(context.Compilation, eventHandler, genericEventHandler, eventArgs, comSourceInterfacesAttribute).AnalyzeSymbol, SymbolKind.Event); }); }
public override void Initialize(AnalysisContext analysisContext) { analysisContext.EnableConcurrentExecution(); analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); analysisContext.RegisterCompilationStartAction( (context) => { INamedTypeSymbol eventHandler = WellKnownTypes.EventHandler(context.Compilation); if (eventHandler == null) { return; } INamedTypeSymbol genericEventHandler = WellKnownTypes.GenericEventHandler(context.Compilation); if (genericEventHandler == null) { return; } INamedTypeSymbol eventArgs = WellKnownTypes.EventArgs(context.Compilation); if (eventArgs == null) { return; } INamedTypeSymbol comSourceInterfacesAttribute = WellKnownTypes.ComSourceInterfaceAttribute(context.Compilation); if (comSourceInterfacesAttribute == null) { return; } context.RegisterSymbolAction(GetAnalyzer(context.Compilation, eventHandler, genericEventHandler, eventArgs, comSourceInterfacesAttribute).AnalyzeSymbol, SymbolKind.Event); }); }
public ICompilationEndedAnalyzer OnCompilationStarted(Compilation compilation, Action <Diagnostic> addDiagnostic, CancellationToken cancellationToken) { var eventHandler = WellKnownTypes.EventHandler(compilation); if (eventHandler == null) { return(null); } var genericEventHandler = WellKnownTypes.GenericEventHandler(compilation); if (genericEventHandler == null) { return(null); } var eventArgs = WellKnownTypes.EventArgs(compilation); if (eventArgs == null) { return(null); } var comSourceInterfacesAttribute = WellKnownTypes.ComSourceInterfaceAttribute(compilation); if (comSourceInterfacesAttribute == null) { return(null); } return(GetAnalyzer(compilation, eventHandler, genericEventHandler, eventArgs, comSourceInterfacesAttribute)); }