-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'CSharpCodeFixTest<,>' helper type
- Loading branch information
1 parent
3340fe7
commit 7b31a16
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...rp.D2D1.WinUI.Tests.SourceGenerators/Helpers/CSharpCodeFixerTest{TAnalyzer,TCodeFixer}.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CodeFixes; | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
|
||
#pragma warning disable IDE0290 | ||
|
||
namespace ComputeSharp.Tests.SourceGenerators.Helpers; | ||
|
||
/// <summary> | ||
/// A custom <see cref="CSharpCodeFixTest{TAnalyzer, TCodeFix, TVerifier}"/> that uses a specific C# language version to parse code. | ||
/// </summary> | ||
/// <typeparam name="TAnalyzer">The type of the analyzer to produce diagnostics.</typeparam> | ||
/// <typeparam name="TCodeFixer">The type of code fix to test.</typeparam> | ||
internal sealed class CSharpCodeFixTest<TAnalyzer, TCodeFixer> : CSharpCodeFixTest<TAnalyzer, TCodeFixer, DefaultVerifier> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
where TCodeFixer : CodeFixProvider, new() | ||
{ | ||
/// <summary> | ||
/// The C# language version to use to parse code. | ||
/// </summary> | ||
private readonly LanguageVersion languageVersion; | ||
|
||
/// <summary> | ||
/// Creates a new <see cref="CSharpCodeFixTest{TAnalyzer, TCodeFix}"/> instance with the specified parameters. | ||
/// </summary> | ||
/// <param name="languageVersion">The C# language version to use to parse code.</param> | ||
public CSharpCodeFixTest(LanguageVersion languageVersion) | ||
{ | ||
this.languageVersion = languageVersion; | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override ParseOptions CreateParseOptions() | ||
{ | ||
return new CSharpParseOptions(this.languageVersion, DocumentationMode.Diagnose); | ||
} | ||
} |