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

Remove feature flag as per the offline discussion

上级 c608c830
......@@ -10770,7 +10770,7 @@ long M(int i)
// and info diagnostic is logged with programmatic suppression information.
var suppressor = new DiagnosticSuppressorForId("CS0078");
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, expectedErrorCount: 0,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" },
additionalFlags: new[] { "/warnAsError" },
includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: suppressor);
Assert.DoesNotContain($"error CS0078", output, StringComparison.Ordinal);
......@@ -10824,21 +10824,20 @@ void M(int i)
suppressor.SuppressionDescriptor.Justification);
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: suppressor,
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
analyzers: suppressor);
Assert.DoesNotContain($"warning CS1522", output, StringComparison.Ordinal);
Assert.Contains($"info SP0001", output, StringComparison.Ordinal);
Assert.Contains(suppressionMessage, output, StringComparison.Ordinal);
// Verify that compiler warning CS1522 is reported as error for /warnaserror.
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);
// Verify that compiler warning CS1522 is suppressed with diagnostic suppressor even with /warnaserror
// and info diagnostic is logged with programmatic suppression information.
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, expectedErrorCount: 0,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" },
additionalFlags: new[] { "/warnAsError" },
includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: suppressor);
Assert.DoesNotContain($"error CS1522", output, StringComparison.Ordinal);
......@@ -10879,21 +10878,20 @@ class C
suppressor.SuppressionDescriptor.Justification);
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: suppressor,
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
analyzers: suppressor);
Assert.DoesNotContain($"warning CS0169", output, StringComparison.Ordinal);
Assert.Contains("info SP0001", output, StringComparison.Ordinal);
Assert.Contains(suppressionMessage, output, StringComparison.Ordinal);
// Verify that compiler warning CS0169 is reported as error for /warnaserror.
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);
// Verify that compiler warning CS0169 is suppressed with diagnostic suppressor even with /warnaserror
// and info diagnostic is logged with programmatic suppression information.
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0, expectedErrorCount: 0,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" },
additionalFlags: new[] { "/warnAsError" },
includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: suppressor);
Assert.DoesNotContain($"error CS0169", output, StringComparison.Ordinal);
......@@ -10921,8 +10919,7 @@ class { }";
// Verify that compiler syntax error CS1001 cannot be suppressed with diagnostic suppressor.
output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: new DiagnosticSuppressorForId("CS1001"),
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
analyzers: new DiagnosticSuppressorForId("CS1001"));
Assert.Contains("error CS1001", output, StringComparison.Ordinal);
CleanupAllGeneratedFiles(srcFile.Path);
......@@ -10948,8 +10945,7 @@ class C
// Verify that compiler error CS0246 cannot be suppressed with diagnostic suppressor.
output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1, includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: new DiagnosticSuppressorForId("CS0246"),
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
analyzers: new DiagnosticSuppressorForId("CS0246"));
Assert.Contains("error CS0246", output, StringComparison.Ordinal);
CleanupAllGeneratedFiles(srcFile.Path);
......@@ -10986,15 +10982,14 @@ class C { }";
var analyzerAndSuppressor = new DiagnosticAnalyzer[] { analyzer, suppressor };
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0,
includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: analyzerAndSuppressor,
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
analyzers: analyzerAndSuppressor);
Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal);
Assert.Contains("info SP0001", output, StringComparison.Ordinal);
Assert.Contains(suppressionMessage, output, StringComparison.Ordinal);
// Verify that analyzer warning is reported as error for /warnaserror.
output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" },
additionalFlags: new[] { "/warnAsError" },
includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: analyzer);
Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal);
......@@ -11002,7 +10997,7 @@ class C { }";
// Verify that analyzer warning is suppressed with diagnostic suppressor even with /warnaserror
// and info diagnostic is logged with programmatic suppression information.
output = VerifyOutput(srcDirectory, srcFile, expectedInfoCount: 1, expectedWarningCount: 0,
additionalFlags: new[] { "/warnAsError", "/features:DiagnosticSuppressor" },
additionalFlags: new[] { "/warnAsError" },
includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: analyzerAndSuppressor);
Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal);
......@@ -11015,8 +11010,7 @@ class C { }";
analyzerAndSuppressor = new DiagnosticAnalyzer[] { analyzer, suppressor };
output = VerifyOutput(srcDirectory, srcFile, expectedWarningCount: 1,
includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: analyzerAndSuppressor,
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
analyzers: analyzerAndSuppressor);
Assert.Contains($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal);
CleanupAllGeneratedFiles(srcFile.Path);
......@@ -11044,8 +11038,7 @@ class C { }";
var analyzerAndSuppressor = new DiagnosticAnalyzer[] { analyzer, suppressor };
output = VerifyOutput(srcDirectory, srcFile, expectedErrorCount: 1,
includeCurrentAssemblyAsAnalyzerReference: false,
analyzers: analyzerAndSuppressor,
additionalFlags: new[] { "/features:DiagnosticSuppressor" });
analyzers: analyzerAndSuppressor);
Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal);
CleanupAllGeneratedFiles(srcFile.Path);
......
......@@ -42,7 +42,7 @@ void M(int i)
}
}";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(
// (7,9): warning CS1522: Empty switch block
// {
......@@ -65,7 +65,7 @@ class C
// warning CS0169: The field 'C.f' is never used
private readonly int f;
}";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(
// (5,26): warning CS0169: The field 'C.f' is never used
// private readonly int f;
......@@ -85,7 +85,7 @@ public void TestNoSuppression_CompilerSyntaxError()
string source = @"
class { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(
// (2,7): error CS1001: Identifier expected
......@@ -106,7 +106,7 @@ class C
void M(UndefinedType x) { }
}";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
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?)
......@@ -123,7 +123,7 @@ public void TestSuppression_MultipleDiagnostics()
{
string source1 = @"class C1 { }";
string source2 = @"class C2 { }";
var compilation = CreateCompilation(new[] { source1, source2 }, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(new[] { source1, source2 });
compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
......@@ -141,7 +141,7 @@ public void TestSuppression_MultipleDiagnostics()
public void TestSuppression_MultipleSuppressors_SameDiagnostic()
{
string source = @"class C1 { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
......@@ -161,7 +161,7 @@ public void TestSuppression_MultipleSuppressors_SameDiagnostic()
public void TestSuppression_MultipleSuppressors_DifferentDiagnostic()
{
string source = @"class C1 { private readonly int f; }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(
// (1,33): warning CS0169: The field 'C1.f' is never used
// class C1 { private readonly int f; }
......@@ -184,7 +184,7 @@ public void TestSuppression_MultipleSuppressors_DifferentDiagnostic()
public void TestNoSuppression_SpecificOptionsTurnsOffSuppressor()
{
string source = @"class C1 { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
......@@ -200,34 +200,12 @@ public void TestNoSuppression_SpecificOptionsTurnsOffSuppressor()
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")]
public void TestSuppression_AnalyzerDiagnostics_SeveritiesAndConfigurableMatrix()
{
string source = @"
class C { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics();
var configurations = new[] { false, true };
......@@ -286,7 +264,7 @@ public void TestExceptionFromSuppressor()
string source = @"
class C { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
......@@ -315,7 +293,7 @@ public void TestUnsupportedSuppressionReported()
string source = @"
class C { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics();
const string supportedSuppressionId = "supportedId";
......@@ -342,7 +320,7 @@ public void TestInvalidDiagnosticSuppressionReported()
{
string source = @"
class C { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics();
const string unsupportedSuppressedId = "UnsupportedId";
......@@ -368,7 +346,7 @@ public void TestNonReportedDiagnosticCannotBeSuppressed()
{
string source = @"
class C { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics();
const string nonReportedDiagnosticId = "NonReportedId";
......@@ -393,7 +371,7 @@ class C { }";
public void TestProgrammaticSuppressionInfo_DiagnosticSuppressor()
{
string source = @"class C1 { }";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithDiagnosticSuppressorFeature);
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics();
var analyzer = new CompilationAnalyzerWithSeverity(DiagnosticSeverity.Warning, configurable: true);
......
......@@ -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>
/// Looks up a localized string similar to Argument contains duplicate analyzer instances..
/// </summary>
......
......@@ -660,9 +660,6 @@
<data name="WRN_InvalidSeverityInAnalyzerConfig_Title" xml:space="preserve">
<value>Invalid severity in analyzer config file.</value>
</data>
<data name="DiagnosticSuppressorFeatureDisabled" xml:space="preserve">
<value>Feature 'DiagnosticSuppressor' is disabled.</value>
</data>
<data name="SuppressionDiagnosticDescriptorTitle" xml:space="preserve">
<value>Programmatic suppression of an analyzer diagnostic</value>
</data>
......
......@@ -25,9 +25,6 @@ internal abstract partial class AnalyzerDriver : IDisposable
// Protect against vicious analyzers that provide large values for SymbolKind.
private const int MaxSymbolKind = 100;
// Feature flag for DiagnosticSuppressor feature
internal const string DiagnosticSuppressorFeatureName = "DiagnosticSuppressor";
// Cache delegates for static methods
private static readonly Func<DiagnosticAnalyzer, bool> s_IsCompilerAnalyzerFunc = IsCompilerAnalyzer;
......
......@@ -1528,11 +1528,6 @@ public void ReportSuppression(Suppression suppression)
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))
{
// Suppression has been disabled by the end user through compilation options.
......
......@@ -19,11 +19,6 @@
{1}.</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
"{1}".</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
'{1}'.</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
'{1}'.</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
'{1}'.</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
'{1}'。</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
'{1}'</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
„{1}”.</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
'{1}'.</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
"{1}".</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
'{1}'.</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
“{1}”。</target>
<note />
</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">
<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>
......
......@@ -19,11 +19,6 @@
'{1}'。</target>
<note />
</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">
<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>
......
......@@ -43,8 +43,6 @@ public static class TestOptions
public static readonly CSharpParseOptions RegularWithoutRecursivePatterns = Regular7_3;
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 ReleaseExe = new CSharpCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel: OptimizationLevel.Release);
......@@ -136,11 +134,6 @@ public static CSharpCompilationOptions WithSpecificDiagnosticOptions(this CSharp
{
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
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 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 ReleaseExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Release).WithParseOptions(Regular)
......@@ -62,9 +61,4 @@ Friend Module TestOptionExtensions
Next
Return options.WithFeatures(options.Features.Concat(list))
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
......@@ -9377,8 +9377,7 @@ End Class"
Dim suppressors = ImmutableArray.Create(Of DiagnosticAnalyzer)(suppressor)
output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0,
includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=suppressors,
additionalFlags:={"/features:DiagnosticSuppressor"})
analyzers:=suppressors)
Assert.DoesNotContain("warning BC40008", output, StringComparison.Ordinal)
Assert.Contains("info SP0001", output, StringComparison.Ordinal)
Assert.Contains(suppressionMessage, output, StringComparison.Ordinal)
......@@ -9410,7 +9409,7 @@ End Class"
Assert.Contains("warning BC40008", output, StringComparison.Ordinal)
' 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)
Assert.Contains("error BC40008", output, StringComparison.Ordinal)
......@@ -9420,7 +9419,7 @@ End Class"
Dim suppressors = ImmutableArray.Create(Of DiagnosticAnalyzer)(suppressor)
output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0, expectedErrorCount:=0,
additionalFlags:={"/warnaserror+", "/features:DiagnosticSuppressor"},
additionalFlags:={"/warnaserror+"},
includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=suppressors)
Assert.DoesNotContain($"warning BC40008", output, StringComparison.Ordinal)
......@@ -9458,8 +9457,7 @@ End Class"
Dim analyzers = ImmutableArray.Create(Of DiagnosticAnalyzer)(New DiagnosticSuppressorForId("BC30203"))
output = VerifyOutput(dir, file, expectedErrorCount:=1,
includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzers,
additionalFlags:={"/features:DiagnosticSuppressor"})
analyzers:=analyzers)
Assert.Contains("error BC30203", output, StringComparison.Ordinal)
CleanupAllGeneratedFiles(file.Path)
......@@ -9497,15 +9495,14 @@ End Class"
Dim analyzerAndSuppressor = ImmutableArray.Create(Of DiagnosticAnalyzer)(analyzer, suppressor)
output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0,
includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzerAndSuppressor,
additionalFlags:={"/features:DiagnosticSuppressor"})
analyzers:=analyzerAndSuppressor)
Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal)
Assert.Contains("info SP0001", output, StringComparison.Ordinal)
Assert.Contains(suppressionMessage, output, StringComparison.Ordinal)
' Verify that analyzer warning is reported as error for /warnaserror.
output = VerifyOutput(dir, file, expectedErrorCount:=1,
additionalFlags:={"/warnaserror+", "/features:DiagnosticSuppressor"},
additionalFlags:={"/warnaserror+"},
includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzers)
Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal)
......@@ -9513,7 +9510,7 @@ End Class"
' Verify that analyzer warning is suppressed with diagnostic suppressor even with /warnaserror
' and info diagnostic is logged with programmatic suppression information.
output = VerifyOutput(dir, file, expectedInfoCount:=1, expectedWarningCount:=0, expectedErrorCount:=0,
additionalFlags:={"/warnaserror+", "/features:DiagnosticSuppressor"},
additionalFlags:={"/warnaserror+"},
includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzerAndSuppressor)
Assert.DoesNotContain($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal)
......@@ -9526,8 +9523,7 @@ End Class"
analyzerAndSuppressor = ImmutableArray.Create(Of DiagnosticAnalyzer)(analyzer, suppressor)
output = VerifyOutput(dir, file, expectedWarningCount:=1,
includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzerAndSuppressor,
additionalFlags:={"/features:DiagnosticSuppressor"})
analyzers:=analyzerAndSuppressor)
Assert.Contains($"warning {analyzer.Descriptor.Id}", output, StringComparison.Ordinal)
CleanupAllGeneratedFiles(file.Path)
......@@ -9556,8 +9552,7 @@ End Class"
Dim analyzerAndSuppressor = ImmutableArray.Create(Of DiagnosticAnalyzer)(analyzer, suppressor)
output = VerifyOutput(dir, file, expectedErrorCount:=1,
includeCurrentAssemblyAsAnalyzerReference:=False,
analyzers:=analyzerAndSuppressor,
additionalFlags:={"/features:DiagnosticSuppressor"})
analyzers:=analyzerAndSuppressor)
Assert.Contains($"error {analyzer.Descriptor.Id}", output, StringComparison.Ordinal)
CleanupAllGeneratedFiles(file.Path)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册