diff --git a/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalysisExclusions.cs b/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalysisExclusions.cs
deleted file mode 100644
index 7415b253a..000000000
--- a/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalysisExclusions.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-
-namespace Microsoft.CodeAnalysis.Testing
-{
- ///
- /// Specifies characteristics of a file which cause diagnostics to not be reported.
- ///
- [Flags]
- public enum AnalysisExclusions
- {
- ///
- /// No special exclusions apply.
- ///
- None = 0,
-
- ///
- /// Analysis will not report diagnostics in generated code.
- ///
- GeneratedCode = 0x01,
-
- ///
- /// Diagnostics will not be reported if a #pragma warning disable appears at the beginning of the file.
- ///
- Suppression = 0x02,
- }
-}
diff --git a/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerTest`1.cs b/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerTest`1.cs
index 5d015f2bc..566ca194c 100644
--- a/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerTest`1.cs
+++ b/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerTest`1.cs
@@ -98,10 +98,10 @@ public string TestCode
public Dictionary XmlReferences { get; } = new Dictionary();
///
- /// Gets or sets a value the analysis exclusions to verify. The default value is a combination of
- /// and .
+ /// Gets or sets the test behaviors applying to this analyzer. The default value is
+ /// .
///
- public AnalysisExclusions Exclusions { get; set; } = AnalysisExclusions.GeneratedCode | AnalysisExclusions.Suppression;
+ public TestBehaviors TestBehaviors { get; set; }
///
/// Gets a collection of diagnostics to explicitly disable in the for projects.
@@ -155,7 +155,7 @@ protected async Task VerifyDiagnosticsAsync((string filename, SourceText content
private async Task VerifyGeneratedCodeDiagnosticsAsync(ImmutableArray analyzers, (string filename, SourceText content)[] sources, (string filename, SourceText content)[] additionalFiles, MetadataReference[] additionalMetadataReferences, DiagnosticResult[] expected, IVerifier verifier, CancellationToken cancellationToken)
{
- if (!Exclusions.HasFlag(AnalysisExclusions.GeneratedCode))
+ if (TestBehaviors.HasFlag(TestBehaviors.SkipGeneratedCodeCheck))
{
return;
}
@@ -180,7 +180,7 @@ private async Task VerifyGeneratedCodeDiagnosticsAsync(ImmutableArray analyzers, (string filename, SourceText content)[] sources, (string filename, SourceText content)[] additionalFiles, MetadataReference[] additionalMetadataReferences, DiagnosticResult[] expected, IVerifier verifier, CancellationToken cancellationToken)
{
- if (!Exclusions.HasFlag(AnalysisExclusions.Suppression))
+ if (TestBehaviors.HasFlag(TestBehaviors.SkipSuppressionCheck))
{
return;
}
diff --git a/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/PublicAPI.Unshipped.txt b/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/PublicAPI.Unshipped.txt
index 6a4394a19..6c2b0f2b8 100644
--- a/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/PublicAPI.Unshipped.txt
+++ b/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/PublicAPI.Unshipped.txt
@@ -1,18 +1,14 @@
-Microsoft.CodeAnalysis.Testing.AnalysisExclusions
-Microsoft.CodeAnalysis.Testing.AnalysisExclusions.GeneratedCode = 1 -> Microsoft.CodeAnalysis.Testing.AnalysisExclusions
-Microsoft.CodeAnalysis.Testing.AnalysisExclusions.None = 0 -> Microsoft.CodeAnalysis.Testing.AnalysisExclusions
-Microsoft.CodeAnalysis.Testing.AnalysisExclusions.Suppression = 2 -> Microsoft.CodeAnalysis.Testing.AnalysisExclusions
Microsoft.CodeAnalysis.Testing.AnalyzerTest
Microsoft.CodeAnalysis.Testing.AnalyzerTest.AnalyzerTest() -> void
Microsoft.CodeAnalysis.Testing.AnalyzerTest.CompilerDiagnostics.get -> Microsoft.CodeAnalysis.Testing.CompilerDiagnostics
Microsoft.CodeAnalysis.Testing.AnalyzerTest.CompilerDiagnostics.set -> void
Microsoft.CodeAnalysis.Testing.AnalyzerTest.CreateProject((string filename, Microsoft.CodeAnalysis.Text.SourceText content)[] sources, (string filename, Microsoft.CodeAnalysis.Text.SourceText content)[] additionalFiles, Microsoft.CodeAnalysis.MetadataReference[] additionalMetadataReferences, string language) -> Microsoft.CodeAnalysis.Project
Microsoft.CodeAnalysis.Testing.AnalyzerTest.DisabledDiagnostics.get -> System.Collections.Generic.List
-Microsoft.CodeAnalysis.Testing.AnalyzerTest.Exclusions.get -> Microsoft.CodeAnalysis.Testing.AnalysisExclusions
-Microsoft.CodeAnalysis.Testing.AnalyzerTest.Exclusions.set -> void
Microsoft.CodeAnalysis.Testing.AnalyzerTest.ExpectedDiagnostics.get -> System.Collections.Generic.List
Microsoft.CodeAnalysis.Testing.AnalyzerTest.OptionsTransforms.get -> System.Collections.Generic.List>
Microsoft.CodeAnalysis.Testing.AnalyzerTest.SolutionTransforms.get -> System.Collections.Generic.List>
+Microsoft.CodeAnalysis.Testing.AnalyzerTest.TestBehaviors.get -> Microsoft.CodeAnalysis.Testing.TestBehaviors
+Microsoft.CodeAnalysis.Testing.AnalyzerTest.TestBehaviors.set -> void
Microsoft.CodeAnalysis.Testing.AnalyzerTest.TestCode.set -> void
Microsoft.CodeAnalysis.Testing.AnalyzerTest.TestState.get -> Microsoft.CodeAnalysis.Testing.SolutionState
Microsoft.CodeAnalysis.Testing.AnalyzerTest.VerifyDiagnosticsAsync((string filename, Microsoft.CodeAnalysis.Text.SourceText content)[] sources, (string filename, Microsoft.CodeAnalysis.Text.SourceText content)[] additionalFiles, Microsoft.CodeAnalysis.MetadataReference[] additionalMetadataReferences, Microsoft.CodeAnalysis.Testing.DiagnosticResult[] expected, Microsoft.CodeAnalysis.Testing.IVerifier verifier, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task
@@ -105,6 +101,10 @@ Microsoft.CodeAnalysis.Testing.StateInheritanceMode
Microsoft.CodeAnalysis.Testing.StateInheritanceMode.AutoInherit = 0 -> Microsoft.CodeAnalysis.Testing.StateInheritanceMode
Microsoft.CodeAnalysis.Testing.StateInheritanceMode.AutoInheritAll = 2 -> Microsoft.CodeAnalysis.Testing.StateInheritanceMode
Microsoft.CodeAnalysis.Testing.StateInheritanceMode.Explicit = 1 -> Microsoft.CodeAnalysis.Testing.StateInheritanceMode
+Microsoft.CodeAnalysis.Testing.TestBehaviors
+Microsoft.CodeAnalysis.Testing.TestBehaviors.None = 0 -> Microsoft.CodeAnalysis.Testing.TestBehaviors
+Microsoft.CodeAnalysis.Testing.TestBehaviors.SkipGeneratedCodeCheck = 1 -> Microsoft.CodeAnalysis.Testing.TestBehaviors
+Microsoft.CodeAnalysis.Testing.TestBehaviors.SkipSuppressionCheck = 2 -> Microsoft.CodeAnalysis.Testing.TestBehaviors
Microsoft.CodeAnalysis.Testing.TestFileMarkupParser
abstract Microsoft.CodeAnalysis.Testing.AnalyzerTest.CreateCompilationOptions() -> Microsoft.CodeAnalysis.CompilationOptions
abstract Microsoft.CodeAnalysis.Testing.AnalyzerTest.DefaultFileExt.get -> string
diff --git a/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/TestBehaviors.cs b/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/TestBehaviors.cs
new file mode 100644
index 000000000..e5fa9211b
--- /dev/null
+++ b/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/TestBehaviors.cs
@@ -0,0 +1,34 @@
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+
+namespace Microsoft.CodeAnalysis.Testing
+{
+ ///
+ /// Specifies non-standard analyzer behaviors which impact testing.
+ ///
+ [Flags]
+ public enum TestBehaviors
+ {
+ ///
+ /// No special behaviors apply.
+ ///
+ None = 0,
+
+ ///
+ /// Skip the generated code exclusion check.
+ ///
+ ///
+ /// By default, the analyzer test framework verifies that analyzer which report diagnostics do not report
+ /// diagnostics in generated code. While some analyzers, e.g. security analyzers, are expected to report
+ /// diagnostics in all code, most analyzers are expected to only report diagnostics in user-created code.
+ ///
+ SkipGeneratedCodeCheck = 0x01,
+
+ ///
+ /// Skip a verification check that diagnostics will not be reported if a #pragma warning disable appears
+ /// at the beginning of the file.
+ ///
+ SkipSuppressionCheck = 0x02,
+ }
+}
diff --git a/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing.UnitTests/AutoExclusionTests.cs b/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing.UnitTests/AutoExclusionTests.cs
index bc6a3203d..504540bc8 100644
--- a/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing.UnitTests/AutoExclusionTests.cs
+++ b/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing.UnitTests/AutoExclusionTests.cs
@@ -106,7 +106,7 @@ public async Task TestCSharpAnalyzerWithoutGeneratedCodeExclusionButAllowedPasse
await new CSharpReplaceThisWithBaseTest(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics)
{
TestCode = ReplaceThisWithBaseTestCode,
- Exclusions = AnalysisExclusions.Suppression,
+ TestBehaviors = TestBehaviors.SkipGeneratedCodeCheck,
}.RunAsync();
}
@@ -116,7 +116,7 @@ public async Task TestCSharpAnalyzerWithoutSuppressionExclusionButAllowedPasses(
await new CSharpAnalyzerTest
{
TestCode = CSharpFirstLineDiagnosticTestCode,
- Exclusions = AnalysisExclusions.GeneratedCode,
+ TestBehaviors = TestBehaviors.SkipSuppressionCheck,
}.RunAsync();
}
@@ -184,7 +184,7 @@ public async Task TestVisualBasicAnalyzerWithoutGeneratedCodeExclusionButAllowed
await new VisualBasicReplaceThisWithBaseTest(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics)
{
TestCode = ReplaceMyClassWithMyBaseTestCode,
- Exclusions = AnalysisExclusions.Suppression,
+ TestBehaviors = TestBehaviors.SkipGeneratedCodeCheck,
}.RunAsync();
}
@@ -194,7 +194,7 @@ public async Task TestVisualBasicAnalyzerWithoutSuppressionExclusionButAllowedPa
await new VisualBasicAnalyzerTest
{
TestCode = VisualBasicFirstLineDiagnosticTestCode,
- Exclusions = AnalysisExclusions.GeneratedCode,
+ TestBehaviors = TestBehaviors.SkipSuppressionCheck,
}.RunAsync();
}