Skip to content

Commit

Permalink
Merge pull request #584 from nschuessler/master
Browse files Browse the repository at this point in the history
Add diagnostic verification extensibility.
  • Loading branch information
sharwell authored Aug 13, 2020
2 parents 612750e + 1fe7f62 commit 6e4a9e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,18 @@ public string TestCode
/// </summary>
public List<string> DisabledDiagnostics { get; } = new List<string>();

/// <summary>
/// Gets or sets the reference assemblies to use.
/// </summary>
public ReferenceAssemblies ReferenceAssemblies { get; set; } = ReferenceAssemblies.Default;

/// <summary>
/// Gets or sets an additional verifier for a diagnostic.
/// The action compares actual <see cref="Diagnostic"/> and the expected
/// <see cref="DiagnosticResult"/> based on custom test requirements not yet supported by the test framework.
/// </summary>
public Action<Diagnostic, DiagnosticResult, IVerifier>? DiagnosticVerifier { get; set; }

/// <summary>
/// Gets a collection of transformation functions to apply to <see cref="Workspace.Options"/> during diagnostic
/// or code fix test setup.
Expand Down Expand Up @@ -371,6 +381,8 @@ private void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResults, Immu
StringComparer.Ordinal,
message);
}

DiagnosticVerifier?.Invoke(actual, expected, verifier);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Microsoft.CodeAnalysis.Testing.AnalyzerTest<TVerifier>.AnalyzerTest() -> void
Microsoft.CodeAnalysis.Testing.AnalyzerTest<TVerifier>.CompilerDiagnostics.get -> Microsoft.CodeAnalysis.Testing.CompilerDiagnostics
Microsoft.CodeAnalysis.Testing.AnalyzerTest<TVerifier>.CompilerDiagnostics.set -> void
Microsoft.CodeAnalysis.Testing.AnalyzerTest<TVerifier>.CreateProjectAsync((string filename, Microsoft.CodeAnalysis.Text.SourceText content)[] sources, (string filename, Microsoft.CodeAnalysis.Text.SourceText content)[] additionalFiles, Microsoft.CodeAnalysis.Testing.ProjectState[] additionalProjects, Microsoft.CodeAnalysis.MetadataReference[] additionalMetadataReferences, string language, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<Microsoft.CodeAnalysis.Project>
Microsoft.CodeAnalysis.Testing.AnalyzerTest<TVerifier>.DiagnosticVerifier.get -> System.Action<Microsoft.CodeAnalysis.Diagnostic, Microsoft.CodeAnalysis.Testing.DiagnosticResult, Microsoft.CodeAnalysis.Testing.IVerifier>
Microsoft.CodeAnalysis.Testing.AnalyzerTest<TVerifier>.DiagnosticVerifier.set -> void
Microsoft.CodeAnalysis.Testing.AnalyzerTest<TVerifier>.DisabledDiagnostics.get -> System.Collections.Generic.List<string>
Microsoft.CodeAnalysis.Testing.AnalyzerTest<TVerifier>.ExpectedDiagnostics.get -> System.Collections.Generic.List<Microsoft.CodeAnalysis.Testing.DiagnosticResult>
Microsoft.CodeAnalysis.Testing.AnalyzerTest<TVerifier>.FormatVerifierMessage(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer> analyzers, Microsoft.CodeAnalysis.Diagnostic actual, Microsoft.CodeAnalysis.Testing.DiagnosticResult expected, string message) -> string
Expand Down

0 comments on commit 6e4a9e4

Please sign in to comment.