Skip to content

Commit

Permalink
Merge pull request #7335 from JakeYallop/add-string-syntax-attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed Aug 2, 2024
2 parents 81d9b5d + 26e5bd1 commit b70b320
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
9 changes: 5 additions & 4 deletions src/Test.Utilities/CSharpCodeFixVerifier`2.cs
Original file line number Diff line number Diff line change
@@ -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.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
Expand All @@ -22,7 +23,7 @@ public static DiagnosticResult Diagnostic(string diagnosticId)
public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor)
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, DefaultVerifier>.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 Test
{
Expand All @@ -33,13 +34,13 @@ public static async Task VerifyAnalyzerAsync(string source, params DiagnosticRes
await test.RunAsync();
}

public static async Task VerifyCodeFixAsync(string source, string fixedSource)
public static async Task VerifyCodeFixAsync([StringSyntax("C#-test")] string source, [StringSyntax("C#-test")] 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, [StringSyntax("C#-test")] string fixedSource)
=> await VerifyCodeFixAsync(source, new[] { expected }, fixedSource);

public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource)
public static async Task VerifyCodeFixAsync([StringSyntax("C#-test")] string source, DiagnosticResult[] expected, [StringSyntax("C#-test")] string fixedSource)
{
var test = new Test
{
Expand Down
7 changes: 4 additions & 3 deletions src/Test.Utilities/CSharpCodeRefactoringVerifier`1.cs
Original file line number Diff line number Diff line change
@@ -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.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.Testing;
Expand All @@ -10,15 +11,15 @@ public static partial class CSharpCodeRefactoringVerifier<TRefactoring>
where TRefactoring : CodeRefactoringProvider, new()
{
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, string)"/>
public static async Task VerifyRefactoringAsync(string source, string fixedSource)
public static async Task VerifyRefactoringAsync([StringSyntax("C#-test")] string source, [StringSyntax("C#-test")] string fixedSource)
=> await VerifyRefactoringAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource);

/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, DiagnosticResult, string)"/>
public static async Task VerifyRefactoringAsync(string source, DiagnosticResult expected, string fixedSource)
public static async Task VerifyRefactoringAsync([StringSyntax("C#-test")] string source, DiagnosticResult expected, [StringSyntax("C#-test")] string fixedSource)
=> await VerifyRefactoringAsync(source, new[] { expected }, fixedSource);

/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, DiagnosticResult[], string)"/>
public static async Task VerifyRefactoringAsync(string source, DiagnosticResult[] expected, string fixedSource)
public static async Task VerifyRefactoringAsync([StringSyntax("C#-test")] string source, DiagnosticResult[] expected, [StringSyntax("C#-test")] string fixedSource)
{
var test = new Test
{
Expand Down
9 changes: 5 additions & 4 deletions src/Test.Utilities/CSharpSecurityCodeFixVerifier`2.cs
Original file line number Diff line number Diff line change
@@ -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.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
Expand All @@ -22,7 +23,7 @@ public static DiagnosticResult Diagnostic(string diagnosticId)
public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor)
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, DefaultVerifier>.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 Test
{
Expand All @@ -32,13 +33,13 @@ public static async Task VerifyAnalyzerAsync(string source, params DiagnosticRes
await RunTestAsync(test, expected);
}

public static Task VerifyCodeFixAsync(string source, string fixedSource)
public static Task VerifyCodeFixAsync([StringSyntax("C#-test")] string source, [StringSyntax("C#-test")] string fixedSource)
=> VerifyCodeFixAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource);

public static Task VerifyCodeFixAsync(string source, DiagnosticResult expected, string fixedSource)
public static Task VerifyCodeFixAsync([StringSyntax("C#-test")] string source, DiagnosticResult expected, [StringSyntax("C#-test")] string fixedSource)
=> VerifyCodeFixAsync(source, new[] { expected }, fixedSource);

public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource)
public static async Task VerifyCodeFixAsync([StringSyntax("C#-test")] string source, DiagnosticResult[] expected, [StringSyntax("C#-test")] string fixedSource)
{
var test = new Test
{
Expand Down

0 comments on commit b70b320

Please sign in to comment.