public static async Task VerifyAsync <TAnalyzer>(this AnnotatedSourceFile sourceFile)
            where TAnalyzer : DiagnosticAnalyzer, new()
        {
            var type = sourceFile.LoadType();

            var expectedDiagnostics = type.GetCustomAttributes <NoExpectedDiagnosticAttribute>().Any()
                ? Array.Empty <DiagnosticResult>()
                : type.GetCustomAttributes <ExpectedDiagnosticAttribute>()
                                      .Select(d => AnalyzerVerifier <TAnalyzer> .Diagnostic(d.DiagnosticId)
                                              .WithLocation(d.Line, d.Column)
                                              .WithArguments(d.Arguments))
                                      .ToArray();

            await AnalyzerVerifier <TAnalyzer> .VerifyAnalyzerAsync(sourceFile.Content, expectedDiagnostics);
        }
 public static DiagnosticResult Diagnostic(string expectedDescriptor) => AnalyzerVerifier <TAnalyzer> .Diagnostic(expectedDescriptor);
Beispiel #3
0
 public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor)
 => AnalyzerVerifier <TAnalyzer, CSharpCodeFixTest <TAnalyzer, TCodeFix, TVerifier>, TVerifier> .Diagnostic(descriptor);
Beispiel #4
0
 public static DiagnosticResult Diagnostic(string diagnosticId)
 => AnalyzerVerifier <TAnalyzer, CSharpCodeFixTest <TAnalyzer, TCodeFix, TVerifier>, TVerifier> .Diagnostic(diagnosticId);
 /// <inheritdoc cref="AnalyzerVerifier{TAnalyzer}.Diagnostic(DiagnosticDescriptor)"/>
 public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor)
 => AnalyzerVerifier <TAnalyzer> .Diagnostic(descriptor);
 /// <inheritdoc cref="AnalyzerVerifier{TAnalyzer}.Diagnostic(string)"/>
 public static DiagnosticResult Diagnostic(string diagnosticId)
 => AnalyzerVerifier <TAnalyzer> .Diagnostic(diagnosticId);
 /// <inheritdoc cref="AnalyzerVerifier{TAnalyzer}.Diagnostic()"/>
 public static DiagnosticResult Diagnostic()
 => AnalyzerVerifier <TAnalyzer> .Diagnostic();
Beispiel #8
0
 public static DiagnosticResult Diagnostic <TDiagnosticAnalyzer>(DiagnosticDescriptor descriptor)
     where TDiagnosticAnalyzer : DiagnosticAnalyzer, new()
 => AnalyzerVerifier <TDiagnosticAnalyzer, CSharpAnalyzerTest <TDiagnosticAnalyzer, XUnitVerifier>, XUnitVerifier> .Diagnostic(descriptor);
Beispiel #9
0
 public static DiagnosticResult Diagnostic <TDiagnosticAnalyzer>(string diagnosticId)
     where TDiagnosticAnalyzer : DiagnosticAnalyzer, new()
 => AnalyzerVerifier <TDiagnosticAnalyzer, CSharpAnalyzerTest <TDiagnosticAnalyzer, XUnitVerifier>, XUnitVerifier> .Diagnostic(diagnosticId);