@@ -67,6 +67,19 @@ static SourceGeneratorUtility()
6767 public T RunGenerator < T > ( EventBuilderCompiler compiler , out ImmutableArray < Diagnostic > compilationDiagnostics , out ImmutableArray < Diagnostic > generatorDiagnostics , out GeneratorDriver generatorDriver , params string [ ] sources )
6868 where T : ISourceGenerator , new ( ) => RunGenerator < T > ( compiler , out compilationDiagnostics , out generatorDiagnostics , out generatorDriver , out _ , out _ , sources ) ;
6969
70+ /// <summary>
71+ /// Runs the generator.
72+ /// </summary>
73+ /// <typeparam name="T">The type of generator.</typeparam>
74+ /// <param name="compiler">The compiler.</param>
75+ /// <param name="compilationDiagnostics">The diagnostics which are produced from the compiler.</param>
76+ /// <param name="generatorDiagnostics">The diagnostics which are produced from the generator.</param>
77+ /// <param name="generatorDriver">Output value for the driver.</param>
78+ /// <param name="sources">The source code files.</param>
79+ /// <returns>The source generator instance.</returns>
80+ public T RunGenerator < T > ( EventBuilderCompiler compiler , out ImmutableArray < Diagnostic > compilationDiagnostics , out ImmutableArray < Diagnostic > generatorDiagnostics , out GeneratorDriver generatorDriver , params ( string FileName , string Source ) [ ] sources )
81+ where T : ISourceGenerator , new ( ) => RunGenerator < T > ( compiler , out compilationDiagnostics , out generatorDiagnostics , out generatorDriver , out _ , out _ , sources ) ;
82+
7083 /// <summary>
7184 /// Runs the generator.
7285 /// </summary>
@@ -80,6 +93,22 @@ public T RunGenerator<T>(EventBuilderCompiler compiler, out ImmutableArray<Diagn
8093 /// <param name="sources">The source code files.</param>
8194 /// <returns>The source generator instance.</returns>
8295 public T RunGenerator < T > ( EventBuilderCompiler compiler , out ImmutableArray < Diagnostic > compilationDiagnostics , out ImmutableArray < Diagnostic > generatorDiagnostics , out GeneratorDriver generatorDriver , out Microsoft . CodeAnalysis . Compilation beforeCompilation , out Microsoft . CodeAnalysis . Compilation afterGeneratorCompilation , params string [ ] sources )
96+ where T : ISourceGenerator , new ( ) =>
97+ RunGenerator < T > ( compiler , out compilationDiagnostics , out generatorDiagnostics , out generatorDriver , out beforeCompilation , out afterGeneratorCompilation , sources . Select ( x => ( FileName : "Unknown File" , Source : x ) ) . ToArray ( ) ) ;
98+
99+ /// <summary>
100+ /// Runs the generator.
101+ /// </summary>
102+ /// <typeparam name="T">The type of generator.</typeparam>
103+ /// <param name="compiler">The compiler.</param>
104+ /// <param name="compilationDiagnostics">The diagnostics which are produced from the compiler.</param>
105+ /// <param name="generatorDiagnostics">The diagnostics which are produced from the generator.</param>
106+ /// <param name="generatorDriver">Output value for the driver.</param>
107+ /// <param name="beforeCompilation">The compilation before the generator has run.</param>
108+ /// <param name="afterGeneratorCompilation">The compilation after the generator has run.</param>
109+ /// <param name="sources">The source code files.</param>
110+ /// <returns>The source generator instance.</returns>
111+ public T RunGenerator < T > ( EventBuilderCompiler compiler , out ImmutableArray < Diagnostic > compilationDiagnostics , out ImmutableArray < Diagnostic > generatorDiagnostics , out GeneratorDriver generatorDriver , out Microsoft . CodeAnalysis . Compilation beforeCompilation , out Microsoft . CodeAnalysis . Compilation afterGeneratorCompilation , params ( string FileName , string Source ) [ ] sources )
83112 where T : ISourceGenerator , new ( )
84113 {
85114 beforeCompilation = CreateCompilation ( compiler , sources ) ;
@@ -109,7 +138,7 @@ private static void ShouldHaveNoCompilerDiagnosticsWarningOrAbove(Action<string>
109138 }
110139 }
111140
112- private static Microsoft . CodeAnalysis . Compilation CreateCompilation ( EventBuilderCompiler compiler , params string [ ] sources )
141+ private static Microsoft . CodeAnalysis . Compilation CreateCompilation ( EventBuilderCompiler compiler , params ( string FileName , string Source ) [ ] sources )
113142 {
114143 var assemblyPath = Path . GetDirectoryName ( typeof ( object ) . Assembly . Location ) ;
115144
@@ -126,7 +155,7 @@ private static Microsoft.CodeAnalysis.Compilation CreateCompilation(EventBuilder
126155
127156 return CSharpCompilation . Create (
128157 "compilation" + Guid . NewGuid ( ) ,
129- sources . Select ( x => CSharpSyntaxTree . ParseText ( x , new CSharpParseOptions ( LanguageVersion . Latest ) ) ) ,
158+ sources . Select ( x => CSharpSyntaxTree . ParseText ( x . Source , new CSharpParseOptions ( LanguageVersion . Latest ) , x . FileName ) ) ,
130159 assemblies ,
131160 new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary , deterministic : true ) ) ;
132161 }
0 commit comments