public static void CreateAndRegisterActions( CompilationStartAnalysisContext context, AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer analyzer) { var attributeSetForMethodsToIgnore = ImmutableHashSet.CreateRange(GetAttributesForMethodsToIgnore(context.Compilation).WhereNotNull()); var eventsArgType = context.Compilation.EventArgsType(); var deserializationConstructorCheck = new DeserializationConstructorCheck(context.Compilation); var iCustomMarshaler = context.Compilation.GetTypeByMetadataName(typeof(ICustomMarshaler).FullName !); context.RegisterSymbolStartAction(symbolStartContext => { if (HasSyntaxErrors((INamedTypeSymbol)symbolStartContext.Symbol, symbolStartContext.CancellationToken)) { // Bail out on syntax errors. return; } // Create a new SymbolStartAnalyzer instance for every named type symbol // to ensure there is no shared state (such as identified unused parameters within the type), // as that would lead to duplicate diagnostics being reported from symbol end action callbacks // for unrelated named types. var symbolAnalyzer = new SymbolStartAnalyzer(analyzer, eventsArgType, attributeSetForMethodsToIgnore, deserializationConstructorCheck, iCustomMarshaler); symbolAnalyzer.OnSymbolStart(symbolStartContext); }, SymbolKind.NamedType); return;
public static void CreateAndRegisterActions( CompilationStartAnalysisContext context, AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer analyzer) { var attributeSetForMethodsToIgnore = ImmutableHashSet.CreateRange(GetAttributesForMethodsToIgnore(context.Compilation).WhereNotNull()); var eventsArgType = context.Compilation.EventArgsType(); context.RegisterSymbolStartAction(symbolStartContext => { // Create a new SymbolStartAnalyzer instance for every named type symbol // to ensure there is no shared state (such as identified unused parameters within the type), // as that would lead to duplicate diagnostics being reported from symbol end action callbacks // for unrelated named types. var symbolAnalyzer = new SymbolStartAnalyzer(analyzer, eventsArgType, attributeSetForMethodsToIgnore); symbolAnalyzer.OnSymbolStart(symbolStartContext); }, SymbolKind.NamedType); }