// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Testing;
namespace CommunityToolkit.Mvvm.SourceGenerators.UnitTests.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.
/// The type of verifier to use to validate the code fixer.
internal sealed class CSharpCodeFixWithLanguageVersionTest : CSharpCodeFixTest
where TAnalyzer : DiagnosticAnalyzer, new()
where TCodeFix : CodeFixProvider, new()
where TVerifier : IVerifier, 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 CSharpCodeFixWithLanguageVersionTest(LanguageVersion languageVersion)
{
this.languageVersion = languageVersion;
}
///
protected override ParseOptions CreateParseOptions()
{
return new CSharpParseOptions(this.languageVersion, DocumentationMode.Diagnose);
}
}