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; /// /// A custom that uses a specific C# language version to parse code. /// /// The type of the analyzer to produce diagnostics. /// The type of code fix to test. internal sealed class CSharpCodeFixTest : CSharpCodeFixTest where TAnalyzer : DiagnosticAnalyzer, new() where TCodeFixer : CodeFixProvider, new() { /// /// The C# language version to use to parse code. /// private readonly LanguageVersion languageVersion; /// /// Creates a new instance with the specified parameters. /// /// The C# language version to use to parse code. public CSharpCodeFixTest(LanguageVersion languageVersion) { this.languageVersion = languageVersion; TestState.AnalyzerConfigFiles.Add(("/.editorconfig", "[*]\nend_of_line = lf")); } /// protected override ParseOptions CreateParseOptions() { return new CSharpParseOptions(this.languageVersion, DocumentationMode.Diagnose); } }