-
-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for the new incremental syntax generator
- Loading branch information
Showing
6 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
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
41 changes: 41 additions & 0 deletions
41
Refit.Tests/Verifiers/CSharpIncrementalSourceGeneratorVerifier`1+Test.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,41 @@ | ||
using System.Collections.Generic; | ||
|
||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
|
||
namespace Refit.Tests | ||
{ | ||
public static partial class CSharpIncrementalSourceGeneratorVerifier<TIncrementalGenerator> | ||
where TIncrementalGenerator : IIncrementalGenerator, new() | ||
{ | ||
public class Test : CSharpSourceGeneratorTest<EmptySourceGeneratorProvider, XUnitVerifier> | ||
{ | ||
public Test() | ||
{ | ||
SolutionTransforms.Add((solution, projectId) => | ||
{ | ||
var compilationOptions = solution.GetProject(projectId).CompilationOptions; | ||
compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( | ||
compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); | ||
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); | ||
return solution; | ||
}); | ||
} | ||
|
||
protected override IEnumerable<ISourceGenerator> GetSourceGenerators() | ||
{ | ||
yield return new TIncrementalGenerator().AsSourceGenerator(); | ||
} | ||
|
||
protected override ParseOptions CreateParseOptions() | ||
{ | ||
var parseOptions = (CSharpParseOptions)base.CreateParseOptions(); | ||
return parseOptions.WithLanguageVersion(LanguageVersion.Preview); | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Refit.Tests/Verifiers/CSharpIncrementalSourceGeneratorVerifier`1.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,9 @@ | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Refit.Tests | ||
{ | ||
public static partial class CSharpIncrementalSourceGeneratorVerifier<TIncrementalGenerator> | ||
where TIncrementalGenerator : IIncrementalGenerator, new() | ||
{ | ||
} | ||
} |