From cc316f3140dbd916ba0f8b7e533641962f50372d Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 22 Jun 2023 11:41:54 -0500 Subject: [PATCH] Enable RS1038 unless .globalconfig provides: roslyn_correctness.assembly_reference_validation = relaxed --- docs/rules/RS1022.md | 8 +- docs/rules/RS1038.md | 3 + .../Core/AnalyzerReleases.Unshipped.md | 6 - .../CompilerExtensionStrictApiAnalyzer.cs | 20 +++ .../DiagnosticAnalyzerAPIUsageAnalyzer.cs | 15 +- .../Microsoft.CodeAnalysis.Analyzers.md | 2 +- .../Microsoft.CodeAnalysis.Analyzers.sarif | 4 +- ...CompilerExtensionStrictApiAnalyzerTests.cs | 54 ++++-- ...DiagnosticAnalyzerApiUsageAnalyzerTests.cs | 157 ++++++++++++++---- 9 files changed, 211 insertions(+), 58 deletions(-) diff --git a/docs/rules/RS1022.md b/docs/rules/RS1022.md index 9f070e3413..ecdb021e08 100644 --- a/docs/rules/RS1022.md +++ b/docs/rules/RS1022.md @@ -5,7 +5,7 @@ Diagnostic analyzer types should not use types from Workspaces assemblies. Works |Item|Value| |-|-| |Category|MicrosoftCodeAnalysisCorrectness| -|Enabled|False| +|Enabled|True| |Severity|Warning| |CodeFix|False| --- @@ -14,3 +14,9 @@ Diagnostic analyzer types should not use types from Workspaces assemblies. Works > > The analysis performed by RS1022 is slow and relies on implementation details of the JIT compiler for correctness. > Authors of compiler extensions are encouraged to use the stricter (and faster) analyzer RS1038 instead of this rule. +> +> RS1038 is enabled by default. To enable RS1022 instead, the following configuration may be added to **.globalconfig**: +> +> ```ini +> roslyn_correctness.assembly_reference_validation = relaxed +> ``` diff --git a/docs/rules/RS1038.md b/docs/rules/RS1038.md index 184606e4b4..e0d73e8db2 100644 --- a/docs/rules/RS1038.md +++ b/docs/rules/RS1038.md @@ -15,6 +15,9 @@ scenarios. Depending on the manner in which the compiler is invoked, some assemb and attempting to reference them will result in exceptions that prevent the compiler extension from loading. RS1038 is the most strict and best performing validation for this scenario. +RS1038 is enabled by default unless relaxed validation has been manually enabled in **.globalconfig** as described in +[RS1022](RS1022.md). + ### Rules for compiler feature references * Compiler features supporting C# code should only reference the NuGet packages **Microsoft.CodeAnalysis.Common** and/or **Microsoft.CodeAnalysis.CSharp** diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Unshipped.md b/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Unshipped.md index be385a9850..0b96acefcc 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Unshipped.md +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/AnalyzerReleases.Unshipped.md @@ -5,9 +5,3 @@ Rule ID | Category | Severity | Notes --------|----------|----------|------- RS1038 | MicrosoftCodeAnalysisCorrectness | Warning | CompilerExtensionStrictApiAnalyzer - -### Changed Rules - -Rule ID | New Category | New Severity | Old Category | Old Severity | Notes ---------|--------------|--------------|--------------|--------------|------- -RS1022 | MicrosoftCodeAnalysisCorrectness | Disabled | MicrosoftCodeAnalysisCorrectness | Warning | DiagnosticAnalyzerApiUsageAnalyzer diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompilerExtensionStrictApiAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompilerExtensionStrictApiAnalyzer.cs index bd338c7dd8..20461ff3a3 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompilerExtensionStrictApiAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompilerExtensionStrictApiAnalyzer.cs @@ -1,5 +1,6 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. +using System; using System.Collections.Immutable; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; @@ -14,6 +15,9 @@ namespace Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] internal sealed class CompilerExtensionStrictApiAnalyzer : DiagnosticAnalyzer { + private const string AssemblyReferenceValidationConfigurationKey = "roslyn_correctness.assembly_reference_validation"; + private const string AssemblyReferenceValidationConfigurationRelaxedValue = "relaxed"; + private static readonly LocalizableString s_localizableTitle = CreateLocalizableResourceString(nameof(DoNotRegisterCompilerTypesWithBadAssemblyReferenceRuleTitle)); private static readonly LocalizableString s_localizableDescription = CreateLocalizableResourceString(nameof(DoNotRegisterCompilerTypesWithBadAssemblyReferenceRuleDescription)); private const string HelpLinkUri = "https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md"; @@ -56,6 +60,12 @@ internal sealed class CompilerExtensionStrictApiAnalyzer : DiagnosticAnalyzer DoNotDeclareCSharpCompilerFeatureInAssemblyWithVisualBasicReferenceStrictRule, DoNotDeclareVisualBasicCompilerFeatureInAssemblyWithCSharpReferenceStrictRule); + internal static bool IsStrictAnalysisEnabled(AnalyzerOptions options) + { + return !options.AnalyzerConfigOptionsProvider.GlobalOptions.TryGetValue(AssemblyReferenceValidationConfigurationKey, out var value) + || !value.Trim().Equals(AssemblyReferenceValidationConfigurationRelaxedValue, StringComparison.Ordinal); + } + public override void Initialize(AnalysisContext context) { context.EnableConcurrentExecution(); @@ -63,6 +73,16 @@ public override void Initialize(AnalysisContext context) context.RegisterCompilationStartAction(context => { + // This analyzer is enabled by default via a configuration option that also applies to RS1022. It needs + // to proceed unless .globalconfig contains the following line to enable it: + // + // roslyn_correctness.assembly_reference_validation = relaxed + if (!IsStrictAnalysisEnabled(context.Options)) + { + // RS1022 is being applied instead of RS1038 + return; + } + var typeProvider = WellKnownTypeProvider.GetOrCreate(context.Compilation); var diagnosticAnalyzer = typeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.MicrosoftCodeAnalysisDiagnosticsDiagnosticAnalyzer); if (diagnosticAnalyzer is null) diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAPIUsageAnalyzer.cs b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAPIUsageAnalyzer.cs index 935985796f..110471e9a2 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAPIUsageAnalyzer.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/DiagnosticAnalyzerAPIUsageAnalyzer.cs @@ -1,5 +1,6 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; @@ -38,7 +39,7 @@ public abstract class DiagnosticAnalyzerApiUsageAnalyzer : Diagnost CreateLocalizableResourceString(nameof(DoNotUseTypesFromAssemblyRuleDirectMessage)), DiagnosticCategory.MicrosoftCodeAnalysisCorrectness, DiagnosticSeverity.Warning, - isEnabledByDefault: false, + isEnabledByDefault: true, description: s_localizableDescription, helpLinkUri: HelpLinkUri, customTags: WellKnownDiagnosticTagsExtensions.CompilationEndAndTelemetry); @@ -49,7 +50,7 @@ public abstract class DiagnosticAnalyzerApiUsageAnalyzer : Diagnost CreateLocalizableResourceString(nameof(DoNotUseTypesFromAssemblyRuleIndirectMessage)), DiagnosticCategory.MicrosoftCodeAnalysisCorrectness, DiagnosticSeverity.Warning, - isEnabledByDefault: false, + isEnabledByDefault: true, description: s_localizableDescription, helpLinkUri: HelpLinkUri, customTags: WellKnownDiagnosticTagsExtensions.CompilationEndAndTelemetry); @@ -64,6 +65,16 @@ public override void Initialize(AnalysisContext context) context.RegisterCompilationStartAction(compilationStartContext => { + // This analyzer is disabled by default via a configuration option that also applies to RS1038. It only + // needs to proceed if .globalconfig contains the following line to enable it: + // + // roslyn_correctness.assembly_reference_validation = relaxed + if (CompilerExtensionStrictApiAnalyzer.IsStrictAnalysisEnabled(compilationStartContext.Options)) + { + // RS1038 is being applied instead of RS1022 + return; + } + if (compilationStartContext.Compilation.GetOrCreateTypeByMetadataName(CodeActionMetadataName) == null) { // No reference to core Workspaces assembly. diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.md b/src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.md index b43d408970..2d45eaeb90 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.md +++ b/src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.md @@ -275,7 +275,7 @@ Diagnostic analyzer types should not use types from Workspaces assemblies. Works |Item|Value| |-|-| |Category|MicrosoftCodeAnalysisCorrectness| -|Enabled|False| +|Enabled|True| |Severity|Warning| |CodeFix|False| --- diff --git a/src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.sarif b/src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.sarif index 4d176eef1d..cc58c42b4f 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.sarif +++ b/src/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.sarif @@ -806,7 +806,7 @@ "helpUri": "https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1022.md", "properties": { "category": "MicrosoftCodeAnalysisCorrectness", - "isEnabledByDefault": false, + "isEnabledByDefault": true, "typeName": "CSharpDiagnosticAnalyzerApiUsageAnalyzer", "languages": [ "C#" @@ -1005,7 +1005,7 @@ "helpUri": "https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1022.md", "properties": { "category": "MicrosoftCodeAnalysisCorrectness", - "isEnabledByDefault": false, + "isEnabledByDefault": true, "typeName": "BasicDiagnosticAnalyzerApiUsageAnalyzer", "languages": [ "Visual Basic" diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/CompilerExtensionStrictApiAnalyzerTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/CompilerExtensionStrictApiAnalyzerTests.cs index 4154ea04f3..7638f792d0 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/CompilerExtensionStrictApiAnalyzerTests.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/CompilerExtensionStrictApiAnalyzerTests.cs @@ -73,18 +73,31 @@ public async Task CSharpFeatureDefinedWithMatchingLanguageReference(CompilerFeat [Theory] [CombinatorialData] - public async Task CSharpFeatureDefinedWithWorkspaceReference(CompilerFeature feature, SupportedLanguage supportedLanguage) + public async Task CSharpFeatureDefinedWithWorkspaceReference(CompilerFeature feature, SupportedLanguage supportedLanguage, bool relaxedValidation) { - await new VerifyCS.Test + var test = new VerifyCS.Test { ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard20.AddPackages(ImmutableArray.Create( new PackageIdentity("Microsoft.CodeAnalysis.Workspaces.Common", CompilerReferenceVersion))), TestCode = DefineFeature(ImplementationLanguage.CSharp, feature, supportedLanguage), - ExpectedDiagnostics = - { - VerifyCS.Diagnostic(CompilerExtensionStrictApiAnalyzer.DoNotDeclareCompilerFeatureInAssemblyWithWorkspacesReferenceStrictRule).WithLocation(0), - }, - }.RunAsync(); + }; + + if (relaxedValidation) + { + test.TestState.AnalyzerConfigFiles.Add( + ("/.globalconfig", + """ + is_global = true + + roslyn_correctness.assembly_reference_validation = relaxed + """)); + } + else + { + test.TestState.ExpectedDiagnostics.Add(VerifyCS.Diagnostic(CompilerExtensionStrictApiAnalyzer.DoNotDeclareCompilerFeatureInAssemblyWithWorkspacesReferenceStrictRule).WithLocation(0)); + } + + await test.RunAsync(); } [Theory] @@ -144,18 +157,31 @@ public async Task VisualBasicFeatureDefinedWithMatchingLanguageReference(Compile [Theory] [CombinatorialData] - public async Task VisualBasicFeatureDefinedWithWorkspaceReference(CompilerFeature feature, SupportedLanguage supportedLanguage) + public async Task VisualBasicFeatureDefinedWithWorkspaceReference(CompilerFeature feature, SupportedLanguage supportedLanguage, bool relaxedValidation) { - await new VerifyVB.Test + var test = new VerifyVB.Test { ReferenceAssemblies = ReferenceAssemblies.NetStandard.NetStandard20.AddPackages(ImmutableArray.Create( new PackageIdentity("Microsoft.CodeAnalysis.Workspaces.Common", CompilerReferenceVersion))), TestCode = DefineFeature(ImplementationLanguage.VisualBasic, feature, supportedLanguage), - ExpectedDiagnostics = - { - VerifyVB.Diagnostic(CompilerExtensionStrictApiAnalyzer.DoNotDeclareCompilerFeatureInAssemblyWithWorkspacesReferenceStrictRule).WithLocation(0), - }, - }.RunAsync(); + }; + + if (relaxedValidation) + { + test.TestState.AnalyzerConfigFiles.Add( + ("/.globalconfig", + """ + is_global = true + + roslyn_correctness.assembly_reference_validation = relaxed + """)); + } + else + { + test.TestState.ExpectedDiagnostics.Add(VerifyVB.Diagnostic(CompilerExtensionStrictApiAnalyzer.DoNotDeclareCompilerFeatureInAssemblyWithWorkspacesReferenceStrictRule).WithLocation(0)); + } + + await test.RunAsync(); } [Theory] diff --git a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticAnalyzerApiUsageAnalyzerTests.cs b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticAnalyzerApiUsageAnalyzerTests.cs index 992867cb46..b0d241bd24 100644 --- a/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticAnalyzerApiUsageAnalyzerTests.cs +++ b/src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DiagnosticAnalyzerApiUsageAnalyzerTests.cs @@ -16,10 +16,56 @@ namespace Microsoft.CodeAnalysis.Analyzers.UnitTests.MetaAnalyzers { public class DiagnosticAnalyzerApiUsageAnalyzerTests { + private static async Task VerifyCSharpAnalyzerAsync(string source, params DiagnosticResult[] expected) + { + var test = new VerifyCS.Test + { + TestState = + { + Sources = { source }, + AnalyzerConfigFiles = + { + ("/.globalconfig", + """ + is_global = true + + roslyn_correctness.assembly_reference_validation = relaxed + """), + } + } + }; + + test.ExpectedDiagnostics.AddRange(expected); + await test.RunAsync(); + } + + private static async Task VerifyVisualBasicAnalyzerAsync(string source, params DiagnosticResult[] expected) + { + var test = new VerifyVB.Test + { + TestState = + { + Sources = { source }, + AnalyzerConfigFiles = + { + ("/.globalconfig", + """ + is_global = true + + roslyn_correctness.assembly_reference_validation = relaxed + """), + } + } + }; + + test.ExpectedDiagnostics.AddRange(expected); + await test.RunAsync(); + } + [Fact] public async Task NoDiagnosticCasesAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -60,7 +106,7 @@ class MyFixer2 : I Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider field; }"); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -111,10 +157,17 @@ End Class "); } - [Fact] - public async Task DirectlyAccessedType_InDeclaration_DiagnosticAsync() + [Theory] + [CombinatorialData] + public async Task DirectlyAccessedType_InDeclaration_DiagnosticAsync(bool relaxedValidation) { - await VerifyCS.VerifyAnalyzerAsync(@" + var csTest = new VerifyCS.Test + { + TestState = + { + Sources = + { + @" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -132,10 +185,33 @@ public override void Initialize(AnalysisContext context) { } }", - // Test0.cs(11,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct accesses to type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider'. - GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider")); - - await VerifyVB.VerifyAnalyzerAsync(@" + }, + } + }; + + if (relaxedValidation) + { + csTest.TestState.AnalyzerConfigFiles.Add( + ("/.globalconfig", + """ + is_global = true + + roslyn_correctness.assembly_reference_validation = relaxed + """)); + csTest.ExpectedDiagnostics.Add( + // Test0.cs(11,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct accesses to type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider'. + GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider")); + } + + await csTest.RunAsync(); + + var vbTest = new VerifyVB.Test + { + TestState = + { + Sources = + { + @" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -160,14 +236,31 @@ Public Overrides Sub Initialize(context As AnalysisContext) End Sub End Class ", - // Test0.vb(12,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct accesses to type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider'. - GetBasicExpectedDiagnostic(0, "MyAnalyzer", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider")); + }, + } + }; + + if (relaxedValidation) + { + vbTest.TestState.AnalyzerConfigFiles.Add( + ("/.globalconfig", + """ + is_global = true + + roslyn_correctness.assembly_reference_validation = relaxed + """)); + vbTest.ExpectedDiagnostics.Add( + // Test0.vb(12,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct accesses to type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider'. + GetBasicExpectedDiagnostic(0, "MyAnalyzer", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider")); + } + + await vbTest.RunAsync(); } [Fact] public async Task DirectlyAccessedType_InMemberDeclaration_DiagnosticAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -193,7 +286,7 @@ public override void Initialize(AnalysisContext context) // Test0.cs(10,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct accesses to type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, Microsoft.CodeAnalysis.CodeFixes.FixAllContext, Microsoft.CodeAnalysis.CodeFixes.FixAllProvider'. GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, Microsoft.CodeAnalysis.CodeFixes.FixAllContext, Microsoft.CodeAnalysis.CodeFixes.FixAllProvider")); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -228,7 +321,7 @@ End Class [Fact] public async Task DirectlyAccessedType_InMemberBody_DiagnosticAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -253,7 +346,7 @@ public override void Initialize(AnalysisContext context) // Test0.cs(10,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct accesses to type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider'. GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider")); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -287,7 +380,7 @@ End Class [Fact] public async Task DirectlyAccessedType_StaticMember_DiagnosticAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -313,7 +406,7 @@ public override void Initialize(AnalysisContext context) // Test0.cs(11,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct accesses to type(s) 'Microsoft.CodeAnalysis.CodeActions.WarningAnnotation'. GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Microsoft.CodeAnalysis.CodeActions.WarningAnnotation")); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -347,7 +440,7 @@ End Class [Fact] public async Task DirectlyAccessedType_StaticMember_02_DiagnosticAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -373,7 +466,7 @@ public override void Initialize(AnalysisContext context) // Test0.cs(11,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct accesses to type(s) 'Microsoft.CodeAnalysis.CodeFixes.FixAllProvider, Microsoft.CodeAnalysis.CodeFixes.WellKnownFixAllProviders'. GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Microsoft.CodeAnalysis.CodeFixes.FixAllProvider, Microsoft.CodeAnalysis.CodeFixes.WellKnownFixAllProviders")); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -407,7 +500,7 @@ End Class [Fact] public async Task DirectlyAccessedType_CastAndTypeCheck_DiagnosticAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -433,7 +526,7 @@ public override void Initialize(AnalysisContext context) // Test0.cs(10,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct accesses to type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, Microsoft.CodeAnalysis.CodeFixes.FixAllProvider'. GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, Microsoft.CodeAnalysis.CodeFixes.FixAllProvider")); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -467,7 +560,7 @@ End Class [Fact] public async Task IndirectlyAccessedType_StaticMember_DiagnosticAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -509,7 +602,7 @@ public sealed override Task RegisterCodeFixesAsync(CodeFixContext context) [Fact] public async Task IndirectlyAccessedType_ExtensionMethod_DiagnosticAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -544,7 +637,7 @@ public static void ExtensionMethod(this DiagnosticAnalyzer analyzer) // Test0.cs(11,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct and/or indirect accesses to type(s) 'FixerExtensions', which access type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider'. GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "FixerExtensions", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider")); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -586,7 +679,7 @@ End Module [Fact] public async Task IndirectlyAccessedType_InvokedFromAnalyzer_DiagnosticAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -620,7 +713,7 @@ public void M() // Test0.cs(10,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct and/or indirect accesses to type(s) 'Class2', which access type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider'. GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Class2", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider")); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -663,7 +756,7 @@ public async Task IndirectlyAccessedType_NotInvokedFromAnalyzer_DiagnosticAsync( // We report diagnostic if there is a transitive access to a type referencing something from Workspaces. // This is regardless of whether the transitive access is actually reachable from a possible code path or not. - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -710,7 +803,7 @@ public void M() // Test0.cs(10,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct and/or indirect accesses to type(s) 'Class2, Class3', which access type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, Microsoft.CodeAnalysis.CodeFixes.FixAllProvider'. GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Class2, Class3", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, Microsoft.CodeAnalysis.CodeFixes.FixAllProvider")); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -758,7 +851,7 @@ End Class [Fact] public async Task IndirectlyAccessedType_Transitive_DiagnosticAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -798,7 +891,7 @@ public void M() // Test0.cs(10,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct and/or indirect accesses to type(s) 'Class3', which access type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider'. GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Class3", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider")); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -841,7 +934,7 @@ End Class [Fact] public async Task TypeDependencyGraphWithCycles_DiagnosticAsync() { - await VerifyCS.VerifyAnalyzerAsync(@" + await VerifyCSharpAnalyzerAsync(@" using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -886,7 +979,7 @@ public void M(Class2 c2) // Test0.cs(10,7): warning RS1022: Change diagnostic analyzer type 'MyAnalyzer' to remove all direct and/or indirect accesses to type(s) 'Class2, Class3', which access type(s) 'Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, Microsoft.CodeAnalysis.CodeFixes.FixAllProvider'. GetCSharpExpectedDiagnostic(0, "MyAnalyzer", "Class2, Class3", "Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, Microsoft.CodeAnalysis.CodeFixes.FixAllProvider")); - await VerifyVB.VerifyAnalyzerAsync(@" + await VerifyVisualBasicAnalyzerAsync(@" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable