private static void Analyze(SyntaxNodeAnalysisContext context, DefaultParamCompilationData compilation) { if (context.Node is not AttributeSyntax syntax || syntax.Parent?.Parent is not CSharpSyntaxNode parent) { return; } INamedTypeSymbol?configurationAttribute = context.SemanticModel.GetSymbolInfo(syntax).Symbol?.ContainingType; if (configurationAttribute is null || !SymbolEqualityComparer.Default.Equals(configurationAttribute, compilation.DefaultParamConfigurationAttribute)) { return; } if (context.SemanticModel.GetDeclaredSymbol(parent) is not ISymbol symbol) { return; } ContextualDiagnosticReceiver <SyntaxNodeAnalysisContext> diagnosticReceiver = DiagnosticReceiverFactory.SyntaxNode(context); if (symbol is INamedTypeSymbol t) { AnalyzeType(diagnosticReceiver, t, compilation, syntax, context.CancellationToken); } else if (symbol is IMethodSymbol m) { AnalyzeMethod(diagnosticReceiver, m, compilation, syntax, context.CancellationToken); } else { ReportConfig(diagnosticReceiver, symbol, syntax); (AttributeArgumentSyntax syntax, string name)[] arguments = GetArguments(syntax);
/// <summary> /// Creates a new instance of the <see cref="ContextualLoggableGeneratorDiagnosticReceiver{T}"/> class that accepts only <see cref="CompilationAnalysisContext"/>. /// </summary> /// <param name="generator">Target <see cref="LoggableSourceGenerator"/>.</param> /// <param name="diagnosticReceiver">Target <see cref="ContextualDiagnosticReceiver{T}"/>.</param> public static ContextualLoggableGeneratorDiagnosticReceiver <CompilationAnalysisContext> Compilation(LoggableSourceGenerator generator, ContextualDiagnosticReceiver <CompilationAnalysisContext> diagnosticReceiver) { return(new ContextualLoggableGeneratorDiagnosticReceiver <CompilationAnalysisContext>(generator, diagnosticReceiver)); }
/// <summary> /// Creates a new instance of the <see cref="ContextualLoggableGeneratorDiagnosticReceiver{T}"/> class that accepts only <see cref="SyntaxTreeAnalysisContext"/>. /// </summary> /// <param name="generator">Target <see cref="LoggableSourceGenerator"/>.</param> /// <param name="diagnosticReceiver">Target <see cref="ContextualDiagnosticReceiver{T}"/>.</param> public static ContextualLoggableGeneratorDiagnosticReceiver <SyntaxTreeAnalysisContext> SyntaxTree(LoggableSourceGenerator generator, ContextualDiagnosticReceiver <SyntaxTreeAnalysisContext> diagnosticReceiver) { return(new ContextualLoggableGeneratorDiagnosticReceiver <SyntaxTreeAnalysisContext>(generator, diagnosticReceiver)); }
/// <summary> /// Creates a new instance of the <see cref="ContextualLoggableGeneratorDiagnosticReceiver{T}"/> class that accepts only <see cref="SemanticModelAnalysisContext"/>. /// </summary> /// <param name="generator">Target <see cref="LoggableSourceGenerator"/>.</param> /// <param name="diagnosticReceiver">Target <see cref="ContextualDiagnosticReceiver{T}"/>.</param> public static ContextualLoggableGeneratorDiagnosticReceiver <SemanticModelAnalysisContext> SemanticModel(LoggableSourceGenerator generator, ContextualDiagnosticReceiver <SemanticModelAnalysisContext> diagnosticReceiver) { return(new ContextualLoggableGeneratorDiagnosticReceiver <SemanticModelAnalysisContext>(generator, diagnosticReceiver)); }
/// <summary> /// Creates a new OperationBlockAnalysisContext of the <see cref="ContextualLoggableGeneratorDiagnosticReceiver{T}"/> class that accepts only <see cref="SymbolAnalysisContext"/>. /// </summary> /// <param name="generator">Target <see cref="LoggableSourceGenerator"/>.</param> /// <param name="diagnosticReceiver">Target <see cref="ContextualDiagnosticReceiver{T}"/>.</param> public static ContextualLoggableGeneratorDiagnosticReceiver <OperationBlockAnalysisContext> OperationBlock(LoggableSourceGenerator generator, ContextualDiagnosticReceiver <OperationBlockAnalysisContext> diagnosticReceiver) { return(new ContextualLoggableGeneratorDiagnosticReceiver <OperationBlockAnalysisContext>(generator, diagnosticReceiver)); }