Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
a47a69ab
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a47a69ab
编写于
6月 18, 2019
作者:
M
Manish Vasani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove feature flag as per the offline discussion
上级
c608c830
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
37 addition
and
169 deletion
+37
-169
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
+14
-21
src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticSuppressorTests.cs
...rp/Test/Semantic/Diagnostics/DiagnosticSuppressorTests.cs
+14
-36
src/Compilers/Core/Portable/CodeAnalysisResources.Designer.cs
...Compilers/Core/Portable/CodeAnalysisResources.Designer.cs
+0
-9
src/Compilers/Core/Portable/CodeAnalysisResources.resx
src/Compilers/Core/Portable/CodeAnalysisResources.resx
+0
-3
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
...pilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
+0
-3
src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
.../Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.cs.xlf
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.cs.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.de.xlf
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.de.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.es.xlf
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.es.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.fr.xlf
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.fr.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.it.xlf
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.it.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.ja.xlf
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.ja.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.ko.xlf
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.ko.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.pl.xlf
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.pl.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.pt-BR.xlf
...mpilers/Core/Portable/xlf/CodeAnalysisResources.pt-BR.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.ru.xlf
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.ru.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.tr.xlf
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.tr.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.zh-Hans.xlf
...ilers/Core/Portable/xlf/CodeAnalysisResources.zh-Hans.xlf
+0
-5
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.zh-Hant.xlf
...ilers/Core/Portable/xlf/CodeAnalysisResources.zh-Hant.xlf
+0
-5
src/Compilers/Test/Utilities/CSharp/TestOptions.cs
src/Compilers/Test/Utilities/CSharp/TestOptions.cs
+0
-7
src/Compilers/Test/Utilities/VisualBasic/TestOptions.vb
src/Compilers/Test/Utilities/VisualBasic/TestOptions.vb
+0
-6
src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
...ompilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
+9
-14
未找到文件。
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
浏览文件 @
a47a69ab
...
...
@@ -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);
...
...
src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticSuppressorTests.cs
浏览文件 @
a47a69ab
...
...
@@ -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
);
...
...
src/Compilers/Core/Portable/CodeAnalysisResources.Designer.cs
浏览文件 @
a47a69ab
...
...
@@ -458,15 +458,6 @@ internal class CodeAnalysisResources {
}
}
/// <summary>
/// Looks up a localized string similar to Feature 'DiagnosticSuppressor' 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>
...
...
src/Compilers/Core/Portable/CodeAnalysisResources.resx
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
浏览文件 @
a47a69ab
...
...
@@ -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
;
...
...
src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs
浏览文件 @
a47a69ab
...
...
@@ -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.
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.cs.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.de.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.es.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.fr.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.it.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.ja.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.ko.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.pl.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.pt-BR.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.ru.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.tr.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.zh-Hans.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Core/Portable/xlf/CodeAnalysisResources.zh-Hant.xlf
浏览文件 @
a47a69ab
...
...
@@ -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>
...
...
src/Compilers/Test/Utilities/CSharp/TestOptions.cs
浏览文件 @
a47a69ab
...
...
@@ -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"
)
}));
}
}
}
src/Compilers/Test/Utilities/VisualBasic/TestOptions.vb
浏览文件 @
a47a69ab
...
...
@@ -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
src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
浏览文件 @
a47a69ab
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录