internal void VerifyCompilerDiagnostics( ImmutableArray <Diagnostic> diagnostics, TestOptions options) { foreach (Diagnostic diagnostic in diagnostics) { if (!options.IsAllowedCompilerDiagnostic(diagnostic)) { Fail($"No compiler diagnostics with severity higher than '{options.AllowedCompilerDiagnosticSeverity}' expected.", diagnostics.Where(d => !options.IsAllowedCompilerDiagnostic(d))); } } }
internal void VerifyCompilerDiagnostics( ImmutableArray <Diagnostic> diagnostics, TestOptions options) { foreach (Diagnostic diagnostic in diagnostics) { if (!options.IsAllowedCompilerDiagnostic(diagnostic)) { Assert.True(false, $"No compiler diagnostics with severity higher than '{options.AllowedCompilerDiagnosticSeverity}' expected" + diagnostics.Where(d => !options.IsAllowedCompilerDiagnostic(d)).ToDebugString()); } } }
internal void VerifyNoNewCompilerDiagnostics( ImmutableArray <Diagnostic> diagnostics, ImmutableArray <Diagnostic> newDiagnostics, TestOptions options) { foreach (Diagnostic newDiagnostic in newDiagnostics) { if (!options.IsAllowedCompilerDiagnostic(newDiagnostic) && IsNewCompilerDiagnostic(newDiagnostic)) { IEnumerable <Diagnostic> diff = newDiagnostics .Where(diagnostic => !options.IsAllowedCompilerDiagnostic(diagnostic)) .Except(diagnostics, DiagnosticDeepEqualityComparer.Instance); var message = "Code fix introduced new compiler diagnostic"; if (diff.Count() > 1) { message += "s"; } message += "."; Fail(message, diff); } } bool IsNewCompilerDiagnostic(Diagnostic newDiagnostic) { foreach (Diagnostic diagnostic in diagnostics) { if (DiagnosticDeepEqualityComparer.Instance.Equals(diagnostic, newDiagnostic)) { return(false); } } return(true); } }