diff --git a/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpAnalyzerVerifier.cs b/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpAnalyzerVerifier.cs index cfbc023573b3..50c40fbad788 100644 --- a/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpAnalyzerVerifier.cs +++ b/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpAnalyzerVerifier.cs @@ -2,15 +2,16 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.InternalTesting; +using Microsoft.AspNetCore.Mvc; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; using Microsoft.Extensions.DependencyInjection; -using Microsoft.AspNetCore.Hosting; namespace Microsoft.AspNetCore.Analyzers.Verifiers; @@ -30,7 +31,7 @@ public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) => CSharpAnalyzerVerifier.Diagnostic(descriptor); /// - public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) + public static async Task VerifyAnalyzerAsync([StringSyntax("C#-test")] string source, params DiagnosticResult[] expected) { var test = new CSharpAnalyzerTest { diff --git a/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpCodeFixVerifier.cs b/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpCodeFixVerifier.cs index c39a1a87e87b..06d8979d58a9 100644 --- a/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpCodeFixVerifier.cs +++ b/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpCodeFixVerifier.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp.Testing; @@ -26,7 +27,7 @@ public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) => CSharpCodeFixVerifier.Diagnostic(descriptor); /// - public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) + public static async Task VerifyAnalyzerAsync([StringSyntax("C#-test")] string source, params DiagnosticResult[] expected) { var test = new CSharpCodeFixTest { @@ -43,15 +44,15 @@ public static async Task VerifyAnalyzerAsync(string source, params DiagnosticRes } /// - public static async Task VerifyCodeFixAsync(string source, string fixedSource) + public static async Task VerifyCodeFixAsync([StringSyntax("C#-test")] string source, string fixedSource) => await VerifyCodeFixAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); /// - public static async Task VerifyCodeFixAsync(string source, DiagnosticResult expected, string fixedSource) + public static async Task VerifyCodeFixAsync([StringSyntax("C#-test")] string source, DiagnosticResult expected, string fixedSource) => await VerifyCodeFixAsync(source, new[] { expected }, fixedSource); /// - public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource, int? expectedIterations = null, string usageSource = null, string codeActionEquivalenceKey = null) + public static async Task VerifyCodeFixAsync([StringSyntax("C#-test")] string source, DiagnosticResult[] expected, string fixedSource, int? expectedIterations = null, string usageSource = null, string codeActionEquivalenceKey = null) { var test = new CSharpCodeFixTest { diff --git a/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpSourceGeneratorVerifier.cs b/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpSourceGeneratorVerifier.cs index 13286b98f26f..f4d70de67467 100644 --- a/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpSourceGeneratorVerifier.cs +++ b/src/Framework/AspNetCoreAnalyzers/test/Verifiers/CSharpSourceGeneratorVerifier.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Text; using Microsoft.AspNetCore.Analyzers.WebApplicationBuilder; using Microsoft.CodeAnalysis; @@ -13,7 +14,7 @@ namespace Microsoft.AspNetCore.Analyzers.Verifiers; public static partial class CSharpSourceGeneratorVerifier where TSourceGenerator : IIncrementalGenerator, new() { - public static async Task VerifyAsync(string source, string generatedFileName, string generatedSource) + public static async Task VerifyAsync([StringSyntax("C#-test")] string source, string generatedFileName, string generatedSource) { var test = new CSharpSourceGeneratorTest { @@ -31,7 +32,7 @@ public static async Task VerifyAsync(string source, string generatedFileName, st await test.RunAsync(CancellationToken.None); } - public static async Task VerifyAsync(string source) + public static async Task VerifyAsync([StringSyntax("C#-test")] string source) { var test = new CSharpSourceGeneratorTest {