1
0

chore: initial commit

Signed-off-by: Alan Brault <alan.brault@visus.io>
This commit is contained in:
2025-07-21 13:43:39 -04:00
commit 90d7bdcd21
37 changed files with 2647 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
namespace MapperSourceGen.SourceGenerator.Tests;
using System.Reflection;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
internal static class Fixture
{
private static readonly Type[] RequiredAssemblies =
[
typeof(Binder),
typeof(MapperAttribute)
];
private static IEnumerable<MetadataReference> AssemblyReferencesForCodeGen =>
AppDomain.CurrentDomain
.GetAssemblies()
.Concat(RequiredAssemblies.Select(s => s.Assembly))
.Distinct()
.Where(w => !w.IsDynamic)
.Select(s => MetadataReference.CreateFromFile(s.Location));
public static Task VerifyGenerateSourcesAsync(string source, params IIncrementalGenerator[] generators)
{
var syntaxTree = CSharpSyntaxTree.ParseText(source, CSharpParseOptions.Default);
var compilation = CSharpCompilation.Create(
"compilation",
[syntaxTree],
AssemblyReferencesForCodeGen,
new CSharpCompilationOptions(OutputKind.ConsoleApplication));
var driver = CSharpGeneratorDriver.Create(generators);
var runner = driver.RunGenerators(compilation);
var verify = Verify(runner);
return verify;
}
}