提交 a47a69ab 编写于 作者: M Manish Vasani

Remove feature flag as per the offline discussion

上级 c608c830
...@@ -10770,7 +10770,7 @@ long M(int i) ...@@ -10770,7 +10770,7 @@ long M(int i)
// and info diagnostic is logged with programmatic suppression information. // and info diagnostic is logged with programmatic suppression information.
var suppressor = new DiagnosticSuppressorForId("CS0078"); var suppressor = new DiagnosticSuppressorForId("CS0078");
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, expectedErrorCount: 0, output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, expectedErrorCount: 0,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" }, additionalFlags: new[] { "/warnAsError" },
includeCurrentAssemblyAsAnalyzerReference: false, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: suppressor); analyzers: suppressor);
Assert.DoesNotContain($"error CS0078", output, StringComparison.Ordinal); Assert.DoesNotContain($"error CS0078", output, StringComparison.Ordinal);
...@@ -10824,21 +10824,20 @@ void M(int i) ...@@ -10824,21 +10824,20 @@ void M(int i)
suppressor.SuppressionDescriptor.Justification); suppressor.SuppressionDescriptor.Justification);
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, includeCurrentAssemblyAsAnalyzerReference: false, output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: suppressor, analyzers: suppressor);
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
Assert.DoesNotContain($"warning CS1522", output, StringComparison.Ordinal); Assert.DoesNotContain($"warning CS1522", output, StringComparison.Ordinal);
Assert.Contains($"info SP0001", output, StringComparison.Ordinal); Assert.Contains($"info SP0001", output, StringComparison.Ordinal);
Assert.Contains(suppressionMessage, output, StringComparison.Ordinal); Assert.Contains(suppressionMessage, output, StringComparison.Ordinal);
// Verify that compiler warning CS1522 is reported as error for /warnaserror. // Verify that compiler warning CS1522 is reported as error for /warnaserror.
output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1, output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" }, includeCurrentAssemblyAsAnalyzerReference: false); additionalFlags: new[] { "/warnAsError" }, includeCurrentAssemblyAsAnalyzerReference: false);
Assert.Contains("error CS1522", output, StringComparison.Ordinal); Assert.Contains("error CS1522", output, StringComparison.Ordinal);
// Verify that compiler warning CS1522 is suppressed with diagnostic suppressor even with /warnaserror // Verify that compiler warning CS1522 is suppressed with diagnostic suppressor even with /warnaserror
// and info diagnostic is logged with programmatic suppression information. // and info diagnostic is logged with programmatic suppression information.
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, expectedErrorCount: 0, output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, expectedErrorCount: 0,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" }, additionalFlags: new[] { "/warnAsError" },
includeCurrentAssemblyAsAnalyzerReference: false, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: suppressor); analyzers: suppressor);
Assert.DoesNotContain($"error CS1522", output, StringComparison.Ordinal); Assert.DoesNotContain($"error CS1522", output, StringComparison.Ordinal);
...@@ -10879,21 +10878,20 @@ class C ...@@ -10879,21 +10878,20 @@ class C
suppressor.SuppressionDescriptor.Justification); suppressor.SuppressionDescriptor.Justification);
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, includeCurrentAssemblyAsAnalyzerReference: false, output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: suppressor, analyzers: suppressor);
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
Assert.DoesNotContain($"warning CS0169", output, StringComparison.Ordinal); Assert.DoesNotContain($"warning CS0169", output, StringComparison.Ordinal);
Assert.Contains("info SP0001", output, StringComparison.Ordinal); Assert.Contains("info SP0001", output, StringComparison.Ordinal);
Assert.Contains(suppressionMessage, output, StringComparison.Ordinal); Assert.Contains(suppressionMessage, output, StringComparison.Ordinal);
// Verify that compiler warning CS0169 is reported as error for /warnaserror. // Verify that compiler warning CS0169 is reported as error for /warnaserror.
output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1, output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" }, includeCurrentAssemblyAsAnalyzerReference: false); additionalFlags: new[] { "/warnAsError" }, includeCurrentAssemblyAsAnalyzerReference: false);
Assert.Contains("error CS0169", output, StringComparison.Ordinal); Assert.Contains("error CS0169", output, StringComparison.Ordinal);
// Verify that compiler warning CS0169 is suppressed with diagnostic suppressor even with /warnaserror // Verify that compiler warning CS0169 is suppressed with diagnostic suppressor even with /warnaserror
// and info diagnostic is logged with programmatic suppression information. // and info diagnostic is logged with programmatic suppression information.
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, expectedErrorCount: 0, output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, expectedErrorCount: 0,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" }, additionalFlags: new[] { "/warnAsError" },
includeCurrentAssemblyAsAnalyzerReference: false, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: suppressor); analyzers: suppressor);
Assert.DoesNotContain($"error CS0169", output, StringComparison.Ordinal); Assert.DoesNotContain($"error CS0169", output, StringComparison.Ordinal);
...@@ -10921,8 +10919,7 @@ class { }"; ...@@ -10921,8 +10919,7 @@ class { }";
// Verify that compiler syntax error CS1001 cannot be suppressed with diagnostic suppressor. // Verify that compiler syntax error CS1001 cannot be suppressed with diagnostic suppressor.
output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1, includeCurrentAssemblyAsAnalyzerReference: false, output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: new DiagnosticSuppressorForId("CS1001"), analyzers: new DiagnosticSuppressorForId("CS1001"));
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
Assert.Contains("error CS1001", output, StringComparison.Ordinal); Assert.Contains("error CS1001", output, StringComparison.Ordinal);
CleanupAllGeneratedFiles(srcFile.Path); CleanupAllGeneratedFiles(srcFile.Path);
...@@ -10948,8 +10945,7 @@ class C ...@@ -10948,8 +10945,7 @@ class C
// Verify that compiler error CS0246 cannot be suppressed with diagnostic suppressor. // Verify that compiler error CS0246 cannot be suppressed with diagnostic suppressor.
output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1, includeCurrentAssemblyAsAnalyzerReference: false, output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: new DiagnosticSuppressorForId("CS0246"), analyzers: new DiagnosticSuppressorForId("CS0246"));
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
Assert.Contains("error CS0246", output, StringComparison.Ordinal); Assert.Contains("error CS0246", output, StringComparison.Ordinal);
CleanupAllGeneratedFiles(srcFile.Path); CleanupAllGeneratedFiles(srcFile.Path);
...@@ -10986,15 +10982,14 @@ class C { }"; ...@@ -10986,15 +10982,14 @@ class C { }";
var analyzerAndSuppressor = new DiagnosticAnalyzer[] { analyzer, suppressor }; var analyzerAndSuppressor = new DiagnosticAnalyzer[] { analyzer, suppressor };
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0,
includeCurrentAssemblyAsAnalyzerReference: false, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: analyzerAndSuppressor, analyzers: analyzerAndSuppressor);
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal); Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal);
Assert.Contains("info SP0001", output, StringComparison.Ordinal); Assert.Contains("info SP0001", output, StringComparison.Ordinal);
Assert.Contains(suppressionMessage, output, StringComparison.Ordinal); Assert.Contains(suppressionMessage, output, StringComparison.Ordinal);
// Verify that analyzer warning is reported as error for /warnaserror. // Verify that analyzer warning is reported as error for /warnaserror.
output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1, output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" }, additionalFlags: new[] { "/warnAsError" },
includeCurrentAssemblyAsAnalyzerReference: false, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: analyzer); analyzers: analyzer);
Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal); Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal);
...@@ -11002,7 +10997,7 @@ class C { }"; ...@@ -11002,7 +10997,7 @@ class C { }";
// Verify that analyzer warning is suppressed with diagnostic suppressor even with /warnaserror // Verify that analyzer warning is suppressed with diagnostic suppressor even with /warnaserror
// and info diagnostic is logged with programmatic suppression information. // and info diagnostic is logged with programmatic suppression information.
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" }, additionalFlags: new[] { "/warnAsError" },
includeCurrentAssemblyAsAnalyzerReference: false, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: analyzerAndSuppressor); analyzers: analyzerAndSuppressor);
Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal); Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal);
...@@ -11015,8 +11010,7 @@ class C { }"; ...@@ -11015,8 +11010,7 @@ class C { }";
analyzerAndSuppressor = new DiagnosticAnalyzer[] { analyzer, suppressor }; analyzerAndSuppressor = new DiagnosticAnalyzer[] { analyzer, suppressor };
output = VerifyOutput(srcDirectory, srcFile, expectedWarningCount: 1, output = VerifyOutput(srcDirectory, srcFile, expectedWarningCount: 1,
includeCurrentAssemblyAsAnalyzerReference: false, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: analyzerAndSuppressor, analyzers: analyzerAndSuppressor);
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
Assert.Contains($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal); Assert.Contains($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal);
CleanupAllGeneratedFiles(srcFile.Path); CleanupAllGeneratedFiles(srcFile.Path);
...@@ -11044,8 +11038,7 @@ class C { }"; ...@@ -11044,8 +11038,7 @@ class C { }";
var analyzerAndSuppressor = new DiagnosticAnalyzer[] { analyzer, suppressor }; var analyzerAndSuppressor = new DiagnosticAnalyzer[] { analyzer, suppressor };
output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1, output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1,
includeCurrentAssemblyAsAnalyzerReference: false, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: analyzerAndSuppressor, analyzers: analyzerAndSuppressor);
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal); Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal);
CleanupAllGeneratedFiles(srcFile.Path); CleanupAllGeneratedFiles(srcFile.Path);
......
...@@ -42,7 +42,7 @@ void M(int i) ...@@ -42,7 +42,7 @@ void M(int i)
} }
}"; }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (7,9): warning CS1522: Empty switch block // (7,9): warning CS1522: Empty switch block
// { // {
...@@ -65,7 +65,7 @@ class C ...@@ -65,7 +65,7 @@ class C
// warning CS0169: The field 'C.f' is never used // warning CS0169: The field 'C.f' is never used
private readonly int f; private readonly int f;
}"; }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (5,26): warning CS0169: The field 'C.f' is never used // (5,26): warning CS0169: The field 'C.f' is never used
// private readonly int f; // private readonly int f;
...@@ -85,7 +85,7 @@ public void TestNoSuppression_CompilerSyntaxError() ...@@ -85,7 +85,7 @@ public void TestNoSuppression_CompilerSyntaxError()
string source = @" string source = @"
class { }"; class { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (2,7): error CS1001: Identifier expected // (2,7): error CS1001: Identifier expected
...@@ -106,7 +106,7 @@ class C ...@@ -106,7 +106,7 @@ class C
void M(UndefinedType x) { } void M(UndefinedType x) { }
}"; }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (4,12): error CS0246: The type or namespace name 'UndefinedType' could not be found (are you missing a using directive or an assembly reference?) // (4,12): error CS0246: The type or namespace name 'UndefinedType' could not be found (are you missing a using directive or an assembly reference?)
...@@ -123,7 +123,7 @@ public void TestSuppression_MultipleDiagnostics() ...@@ -123,7 +123,7 @@ public void TestSuppression_MultipleDiagnostics()
{ {
string source1 = @"class C1 { }"; string source1 = @"class C1 { }";
string source2 = @"class C2 { }"; string source2 = @"class C2 { }";
var compilation = CreateCompilation(new[] { source1, source2 }, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(new[] { source1, source2 });
compilation.VerifyDiagnostics(); compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true); var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
...@@ -141,7 +141,7 @@ public void TestSuppression_MultipleDiagnostics() ...@@ -141,7 +141,7 @@ public void TestSuppression_MultipleDiagnostics()
public void TestSuppression_MultipleSuppressors_SameDiagnostic() public void TestSuppression_MultipleSuppressors_SameDiagnostic()
{ {
string source = @"class C1 { }"; string source = @"class C1 { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(); compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true); var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
...@@ -161,7 +161,7 @@ public void TestSuppression_MultipleSuppressors_SameDiagnostic() ...@@ -161,7 +161,7 @@ public void TestSuppression_MultipleSuppressors_SameDiagnostic()
public void TestSuppression_MultipleSuppressors_DifferentDiagnostic() public void TestSuppression_MultipleSuppressors_DifferentDiagnostic()
{ {
string source = @"class C1 { private readonly int f; }"; string source = @"class C1 { private readonly int f; }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics( compilation.VerifyDiagnostics(
// (1,33): warning CS0169: The field 'C1.f' is never used // (1,33): warning CS0169: The field 'C1.f' is never used
// class C1 { private readonly int f; } // class C1 { private readonly int f; }
...@@ -184,7 +184,7 @@ public void TestSuppression_MultipleSuppressors_DifferentDiagnostic() ...@@ -184,7 +184,7 @@ public void TestSuppression_MultipleSuppressors_DifferentDiagnostic()
public void TestNoSuppression_SpecificOptionsTurnsOffSuppressor() public void TestNoSuppression_SpecificOptionsTurnsOffSuppressor()
{ {
string source = @"class C1 { }"; string source = @"class C1 { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(); compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true); var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
...@@ -200,34 +200,12 @@ public void TestNoSuppression_SpecificOptionsTurnsOffSuppressor() ...@@ -200,34 +200,12 @@ public void TestNoSuppression_SpecificOptionsTurnsOffSuppressor()
VerifySuppressedDiagnostics(compilation, analyzersAndSuppressors); VerifySuppressedDiagnostics(compilation, analyzersAndSuppressors);
} }
[Fact, WorkItem(20242, "https://github.com/dotnet/roslyn/issues/20242")]
public void TestDiagnosticOnMissingFeatureFlag()
{
string source = @"class C1 { }";
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
var analyzerDiagnostic = Diagnostic(analyzer.Descriptor.Id, source);
VerifyAnalyzerDiagnostics(compilation, new DiagnosticAnalyzer[] { analyzer }, analyzerDiagnostic);
var analyzersAndSuppressors = new DiagnosticAnalyzer[] { analyzer, new DiagnosticSuppressorForId(analyzer.Descriptor.Id, "SPR1001") };
var expectedDiagnostics = new[]
{
analyzerDiagnostic,
Diagnostic("AD0001").WithArguments("Microsoft.CodeAnalysis.CommonDiagnosticAnalyzers+DiagnosticSuppressorForId",
"System.ArgumentException",
CodeAnalysisResources.DiagnosticSuppressorFeatureDisabled).WithLocation(1, 1)
};
VerifyAnalyzerDiagnostics(compilation, analyzersAndSuppressors, expectedDiagnostics);
}
[Fact, WorkItem(20242, "https://github.com/dotnet/roslyn/issues/20242")] [Fact, WorkItem(20242, "https://github.com/dotnet/roslyn/issues/20242")]
public void TestSuppression_AnalyzerDiagnostics_SeveritiesAndConfigurableMatrix() public void TestSuppression_AnalyzerDiagnostics_SeveritiesAndConfigurableMatrix()
{ {
string source = @" string source = @"
class C { }"; class C { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(); compilation.VerifyDiagnostics();
var configurations = new[] { false, true }; var configurations = new[] { false, true };
...@@ -286,7 +264,7 @@ public void TestExceptionFromSuppressor() ...@@ -286,7 +264,7 @@ public void TestExceptionFromSuppressor()
string source = @" string source = @"
class C { }"; class C { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(); compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true); var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
...@@ -315,7 +293,7 @@ public void TestUnsupportedSuppressionReported() ...@@ -315,7 +293,7 @@ public void TestUnsupportedSuppressionReported()
string source = @" string source = @"
class C { }"; class C { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(); compilation.VerifyDiagnostics();
const string supportedSuppressionId = "supportedId"; const string supportedSuppressionId = "supportedId";
...@@ -342,7 +320,7 @@ public void TestInvalidDiagnosticSuppressionReported() ...@@ -342,7 +320,7 @@ public void TestInvalidDiagnosticSuppressionReported()
{ {
string source = @" string source = @"
class C { }"; class C { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(); compilation.VerifyDiagnostics();
const string unsupportedSuppressedId = "UnsupportedId"; const string unsupportedSuppressedId = "UnsupportedId";
...@@ -368,7 +346,7 @@ public void TestNonReportedDiagnosticCannotBeSuppressed() ...@@ -368,7 +346,7 @@ public void TestNonReportedDiagnosticCannotBeSuppressed()
{ {
string source = @" string source = @"
class C { }"; class C { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(); compilation.VerifyDiagnostics();
const string nonReportedDiagnosticId = "NonReportedId"; const string nonReportedDiagnosticId = "NonReportedId";
...@@ -393,7 +371,7 @@ class C { }"; ...@@ -393,7 +371,7 @@ class C { }";
public void TestProgrammaticSuppressionInfo_DiagnosticSuppressor() public void TestProgrammaticSuppressionInfo_DiagnosticSuppressor()
{ {
string source = @"class C1 { }"; string source = @"class C1 { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature); var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(); compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true); var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
......
...@@ -458,15 +458,6 @@ internal class CodeAnalysisResources { ...@@ -458,15 +458,6 @@ internal class CodeAnalysisResources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Feature &apos;DiagnosticSuppressor&apos; is disabled..
/// </summary>
internal static string DiagnosticSuppressorFeatureDisabled {
get {
return ResourceManager.GetString("DiagnosticSuppressorFeatureDisabled", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Argument contains duplicate analyzer instances.. /// Looks up a localized string similar to Argument contains duplicate analyzer instances..
/// </summary> /// </summary>
......
...@@ -660,9 +660,6 @@ ...@@ -660,9 +660,6 @@
<data name="WRN_InvalidSeverityInAnalyzerConfig_Title" xml:space="preserve"> <data name="WRN_InvalidSeverityInAnalyzerConfig_Title" xml:space="preserve">
<value>Invalid severity in analyzer config file.</value> <value>Invalid severity in analyzer config file.</value>
</data> </data>
<data name="DiagnosticSuppressorFeatureDisabled" xml:space="preserve">
<value>Feature 'DiagnosticSuppressor' is disabled.</value>
</data>
<data name="SuppressionDiagnosticDescriptorTitle" xml:space="preserve"> <data name="SuppressionDiagnosticDescriptorTitle" xml:space="preserve">
<value>Programmatic suppression of an analyzer diagnostic</value> <value>Programmatic suppression of an analyzer diagnostic</value>
</data> </data>
......
...@@ -25,9 +25,6 @@ internal abstract partial class AnalyzerDriver : IDisposable ...@@ -25,9 +25,6 @@ internal abstract partial class AnalyzerDriver : IDisposable
// Protect against vicious analyzers that provide large values for SymbolKind. // Protect against vicious analyzers that provide large values for SymbolKind.
private const int MaxSymbolKind = 100; private const int MaxSymbolKind = 100;
// Feature flag for DiagnosticSuppressor feature
internal const string DiagnosticSuppressorFeatureName = "DiagnosticSuppressor";
// Cache delegates for static methods // Cache delegates for static methods
private static readonly Func<DiagnosticAnalyzer, bool> s_IsCompilerAnalyzerFunc = IsCompilerAnalyzer; private static readonly Func<DiagnosticAnalyzer, bool> s_IsCompilerAnalyzerFunc = IsCompilerAnalyzer;
......
...@@ -1528,11 +1528,6 @@ public void ReportSuppression(Suppression suppression) ...@@ -1528,11 +1528,6 @@ public void ReportSuppression(Suppression suppression)
throw new ArgumentException(message); throw new ArgumentException(message);
} }
if (!Compilation.SyntaxTrees.Any(t => t.Options.Features.ContainsKey(AnalyzerDriver.DiagnosticSuppressorFeatureName)))
{
throw new ArgumentException(CodeAnalysisResources.DiagnosticSuppressorFeatureDisabled);
}
if (suppression.Descriptor.IsDisabled(Compilation.Options)) if (suppression.Descriptor.IsDisabled(Compilation.Options))
{ {
// Suppression has been disabled by the end user through compilation options. // Suppression has been disabled by the end user through compilation options.
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
{1}.</target> {1}.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
"{1}".</target> "{1}".</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
'{1}'.</target> '{1}'.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
'{1}'.</target> '{1}'.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
'{1}'.</target> '{1}'.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
'{1}'。</target> '{1}'。</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
'{1}'</target> '{1}'</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
„{1}”.</target> „{1}”.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
'{1}'.</target> '{1}'.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
"{1}".</target> "{1}".</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
'{1}'.</target> '{1}'.</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
“{1}”。</target> “{1}”。</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
'{1}'。</target> '{1}'。</target>
<note /> <note />
</trans-unit> </trans-unit>
<trans-unit id="DiagnosticSuppressorFeatureDisabled">
<source>Feature 'DiagnosticSuppressor' is disabled.</source>
<target state="new">Feature 'DiagnosticSuppressor' is disabled.</target>
<note />
</trans-unit>
<trans-unit id="InvalidDiagnosticSuppressionReported"> <trans-unit id="InvalidDiagnosticSuppressionReported">
<source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source> <source>Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</source>
<target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target> <target state="new">Suppressed diagnostic ID '{0}' does not match suppressable ID '{1}' for the given suppression descriptor.</target>
......
...@@ -43,8 +43,6 @@ public static class TestOptions ...@@ -43,8 +43,6 @@ public static class TestOptions
public static readonly CSharpParseOptions RegularWithoutRecursivePatterns = Regular7_3; public static readonly CSharpParseOptions RegularWithoutRecursivePatterns = Regular7_3;
public static readonly CSharpParseOptions RegularWithRecursivePatterns = Regular8; public static readonly CSharpParseOptions RegularWithRecursivePatterns = Regular8;
public static readonly CSharpParseOptions RegularWithDiagnosticSuppressorFeature = Regular.WithDiagnosticSuppressorFeature();
public static readonly CSharpCompilationOptions ReleaseDll = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release); public static readonly CSharpCompilationOptions ReleaseDll = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release);
public static readonly CSharpCompilationOptions ReleaseExe = new CSharpCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel: OptimizationLevel.Release); public static readonly CSharpCompilationOptions ReleaseExe = new CSharpCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel: OptimizationLevel.Release);
...@@ -136,11 +134,6 @@ public static CSharpCompilationOptions WithSpecificDiagnosticOptions(this CSharp ...@@ -136,11 +134,6 @@ public static CSharpCompilationOptions WithSpecificDiagnosticOptions(this CSharp
{ {
return options.WithSpecificDiagnosticOptions(ImmutableDictionary<string, ReportDiagnostic>.Empty.Add(key1, value).Add(key2, value)); return options.WithSpecificDiagnosticOptions(ImmutableDictionary<string, ReportDiagnostic>.Empty.Add(key1, value).Add(key2, value));
} }
public static CSharpParseOptions WithDiagnosticSuppressorFeature(this CSharpParseOptions options)
{
return options.WithFeatures(options.Features.Concat(new[] { new KeyValuePair<string, string>(AnalyzerDriver.DiagnosticSuppressorFeatureName, "true") }));
}
} }
} }
...@@ -11,7 +11,6 @@ Public Class TestOptions ...@@ -11,7 +11,6 @@ Public Class TestOptions
Public Shared ReadOnly Regular As New VisualBasicParseOptions(kind:=SourceCodeKind.Regular, languageVersion:=LanguageVersion.VisualBasic16) Public Shared ReadOnly Regular As New VisualBasicParseOptions(kind:=SourceCodeKind.Regular, languageVersion:=LanguageVersion.VisualBasic16)
Public Shared ReadOnly Regular15_5 As VisualBasicParseOptions = Regular.WithLanguageVersion(LanguageVersion.VisualBasic15_5) Public Shared ReadOnly Regular15_5 As VisualBasicParseOptions = Regular.WithLanguageVersion(LanguageVersion.VisualBasic15_5)
Public Shared ReadOnly RegularWithLegacyStrongName As VisualBasicParseOptions = Regular.WithFeature("UseLegacyStrongNameProvider") Public Shared ReadOnly RegularWithLegacyStrongName As VisualBasicParseOptions = Regular.WithFeature("UseLegacyStrongNameProvider")
Public Shared ReadOnly RegularWithDiagnosticSuppressorFeature As VisualBasicParseOptions = Regular.WithDiagnosticSuppressorFeature()
Public Shared ReadOnly ReleaseDll As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular) Public Shared ReadOnly ReleaseDll As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)
Public Shared ReadOnly ReleaseExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular) Public Shared ReadOnly ReleaseExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)
...@@ -62,9 +61,4 @@ Friend Module TestOptionExtensions ...@@ -62,9 +61,4 @@ Friend Module TestOptionExtensions
Next Next
Return options.WithFeatures(options.Features.Concat(list)) Return options.WithFeatures(options.Features.Concat(list))
End Function End Function
<Extension()>
Public Function WithDiagnosticSuppressorFeature(options As VisualBasicParseOptions) As VisualBasicParseOptions
Return options.WithFeatures(options.Features.Concat({New KeyValuePair(Of String, String)(AnalyzerDriver.DiagnosticSuppressorFeatureName, "true")}))
End Function
End Module End Module
...@@ -9377,8 +9377,7 @@ End Class" ...@@ -9377,8 +9377,7 @@ End Class"
Dim suppressors = ImmutableArray.Create(Of DiagnosticAnalyzer)(suppressor) Dim suppressors = ImmutableArray.Create(Of DiagnosticAnalyzer)(suppressor)
output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0, output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0,
includeCurrentAssemblyAsAnalyzerReference:=False, includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=suppressors, analyzers:=suppressors)
additionalFlags:={"/features:DiagnosticSuppressor"})
Assert.DoesNotContain("warning BC40008", output, StringComparison.Ordinal) Assert.DoesNotContain("warning BC40008", output, StringComparison.Ordinal)
Assert.Contains("info SP0001", output, StringComparison.Ordinal) Assert.Contains("info SP0001", output, StringComparison.Ordinal)
Assert.Contains(suppressionMessage, output, StringComparison.Ordinal) Assert.Contains(suppressionMessage, output, StringComparison.Ordinal)
...@@ -9410,7 +9409,7 @@ End Class" ...@@ -9410,7 +9409,7 @@ End Class"
Assert.Contains("warning BC40008", output, StringComparison.Ordinal) Assert.Contains("warning BC40008", output, StringComparison.Ordinal)
' Verify that compiler warning BC40008 is reported as error for /warnaserror. ' Verify that compiler warning BC40008 is reported as error for /warnaserror.
output = VerifyOutput(dir, file, expectedErrorCount:=1, additionalFlags:={"/warnaserror+", "/features:DiagnosticSuppressor"}, output = VerifyOutput(dir, file, expectedErrorCount:=1, additionalFlags:={"/warnaserror+"},
includeCurrentAssemblyAsAnalyzerReference:=False) includeCurrentAssemblyAsAnalyzerReference:=False)
Assert.Contains("error BC40008", output, StringComparison.Ordinal) Assert.Contains("error BC40008", output, StringComparison.Ordinal)
...@@ -9420,7 +9419,7 @@ End Class" ...@@ -9420,7 +9419,7 @@ End Class"
Dim suppressors = ImmutableArray.Create(Of DiagnosticAnalyzer)(suppressor) Dim suppressors = ImmutableArray.Create(Of DiagnosticAnalyzer)(suppressor)
output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0, expectedErrorCount:=0, output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0, expectedErrorCount:=0,
additionalFlags:={"/warnaserror+", "/features:DiagnosticSuppressor"}, additionalFlags:={"/warnaserror+"},
includeCurrentAssemblyAsAnalyzerReference:=False, includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=suppressors) analyzers:=suppressors)
Assert.DoesNotContain($"warning BC40008", output, StringComparison.Ordinal) Assert.DoesNotContain($"warning BC40008", output, StringComparison.Ordinal)
...@@ -9458,8 +9457,7 @@ End Class" ...@@ -9458,8 +9457,7 @@ End Class"
Dim analyzers = ImmutableArray.Create(Of DiagnosticAnalyzer)(New DiagnosticSuppressorForId("BC30203")) Dim analyzers = ImmutableArray.Create(Of DiagnosticAnalyzer)(New DiagnosticSuppressorForId("BC30203"))
output = VerifyOutput(dir, file, expectedErrorCount:=1, output = VerifyOutput(dir, file, expectedErrorCount:=1,
includeCurrentAssemblyAsAnalyzerReference:=False, includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzers, analyzers:=analyzers)
additionalFlags:={"/features:DiagnosticSuppressor"})
Assert.Contains("error BC30203", output, StringComparison.Ordinal) Assert.Contains("error BC30203", output, StringComparison.Ordinal)
CleanupAllGeneratedFiles(file.Path) CleanupAllGeneratedFiles(file.Path)
...@@ -9497,15 +9495,14 @@ End Class" ...@@ -9497,15 +9495,14 @@ End Class"
Dim analyzerAndSuppressor = ImmutableArray.Create(Of DiagnosticAnalyzer)(analyzer, suppressor) Dim analyzerAndSuppressor = ImmutableArray.Create(Of DiagnosticAnalyzer)(analyzer, suppressor)
output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0, output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0,
includeCurrentAssemblyAsAnalyzerReference:=False, includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzerAndSuppressor, analyzers:=analyzerAndSuppressor)
additionalFlags:={"/features:DiagnosticSuppressor"})
Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal) Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal)
Assert.Contains("info SP0001", output, StringComparison.Ordinal) Assert.Contains("info SP0001", output, StringComparison.Ordinal)
Assert.Contains(suppressionMessage, output, StringComparison.Ordinal) Assert.Contains(suppressionMessage, output, StringComparison.Ordinal)
' Verify that analyzer warning is reported as error for /warnaserror. ' Verify that analyzer warning is reported as error for /warnaserror.
output = VerifyOutput(dir, file, expectedErrorCount:=1, output = VerifyOutput(dir, file, expectedErrorCount:=1,
additionalFlags:={"/warnaserror+", "/features:DiagnosticSuppressor"}, additionalFlags:={"/warnaserror+"},
includeCurrentAssemblyAsAnalyzerReference:=False, includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzers) analyzers:=analyzers)
Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal) Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal)
...@@ -9513,7 +9510,7 @@ End Class" ...@@ -9513,7 +9510,7 @@ End Class"
' Verify that analyzer warning is suppressed with diagnostic suppressor even with /warnaserror ' Verify that analyzer warning is suppressed with diagnostic suppressor even with /warnaserror
' and info diagnostic is logged with programmatic suppression information. ' and info diagnostic is logged with programmatic suppression information.
output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0, expectedErrorCount:=0, output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0, expectedErrorCount:=0,
additionalFlags:={"/warnaserror+", "/features:DiagnosticSuppressor"}, additionalFlags:={"/warnaserror+"},
includeCurrentAssemblyAsAnalyzerReference:=False, includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzerAndSuppressor) analyzers:=analyzerAndSuppressor)
Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal) Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal)
...@@ -9526,8 +9523,7 @@ End Class" ...@@ -9526,8 +9523,7 @@ End Class"
analyzerAndSuppressor = ImmutableArray.Create(Of DiagnosticAnalyzer)(analyzer, suppressor) analyzerAndSuppressor = ImmutableArray.Create(Of DiagnosticAnalyzer)(analyzer, suppressor)
output = VerifyOutput(dir, file, expectedWarningCount:=1, output = VerifyOutput(dir, file, expectedWarningCount:=1,
includeCurrentAssemblyAsAnalyzerReference:=False, includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzerAndSuppressor, analyzers:=analyzerAndSuppressor)
additionalFlags:={"/features:DiagnosticSuppressor"})
Assert.Contains($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal) Assert.Contains($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal)
CleanupAllGeneratedFiles(file.Path) CleanupAllGeneratedFiles(file.Path)
...@@ -9556,8 +9552,7 @@ End Class" ...@@ -9556,8 +9552,7 @@ End Class"
Dim analyzerAndSuppressor = ImmutableArray.Create(Of DiagnosticAnalyzer)(analyzer, suppressor) Dim analyzerAndSuppressor = ImmutableArray.Create(Of DiagnosticAnalyzer)(analyzer, suppressor)
output = VerifyOutput(dir, file, expectedErrorCount:=1, output = VerifyOutput(dir, file, expectedErrorCount:=1,
includeCurrentAssemblyAsAnalyzerReference:=False, includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzerAndSuppressor, analyzers:=analyzerAndSuppressor)
additionalFlags:={"/features:DiagnosticSuppressor"})
Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal) Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal)
CleanupAllGeneratedFiles(file.Path) CleanupAllGeneratedFiles(file.Path)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册