public override void Initialize(AnalysisContext analysisContext) #pragma warning restore RS1026 // Enable concurrent execution { // TODO: Make analyzer thread-safe. //analysisContext.EnableConcurrentExecution(); // Security analyzer - analyze and report diagnostics in generated code. analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); analysisContext.RegisterCompilationStartAction( (context) => { Compilation compilation = context.Compilation; var xmlTypes = new CompilationSecurityTypes(compilation); if (ReferencesAnyTargetType(xmlTypes)) { Version version = SecurityDiagnosticHelpers.GetDotNetFrameworkVersion(compilation); // bail if we are not analyzing project targeting .NET Framework // TODO: should we throw an exception to notify user? if (version != null) { SymbolAndNodeAnalyzer analyzer = GetAnalyzer(context, xmlTypes, version); context.RegisterSymbolAction(analyzer.AnalyzeSymbol, SymbolKind.NamedType); } } }); }
public override void Initialize(AnalysisContext analysisContext) #pragma warning restore RS1026 // Enable concurrent execution { // TODO: Make analyzer thread-safe //analysisContext.EnableConcurrentExecution(); // Security analyzer - analyze and report diagnostics in generated code. analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); analysisContext.RegisterCompilationStartAction( (context) => { Compilation compilation = context.Compilation; var xmlTypes = new CompilationSecurityTypes(compilation); if (ReferencesAnyTargetType(xmlTypes)) { Version version = SecurityDiagnosticHelpers.GetDotNetFrameworkVersion(compilation); if (version != null) { context.RegisterOperationBlockStartAction( (c) => { RegisterAnalyzer(c, xmlTypes, version); }); } } }); }