@@ -71,16 +71,17 @@ public SourceGeneratorUtility(Action<string> writeOutput)
7171 /// <param name="compiler">The compiler.</param>
7272 /// <param name="compilationDiagnostics">The diagnostics which are produced from the compiler.</param>
7373 /// <param name="generatorDiagnostics">The diagnostics which are produced from the generator.</param>
74+ /// <param name="generatorDriver">Output value for the driver.</param>
7475 /// <param name="sources">The source code files.</param>
7576 /// <returns>The source generator instance.</returns>
76- public T RunGenerator < T > ( EventBuilderCompiler compiler , out ImmutableArray < Diagnostic > compilationDiagnostics , out ImmutableArray < Diagnostic > generatorDiagnostics , params string [ ] sources )
77+ public T RunGenerator < T > ( EventBuilderCompiler compiler , out ImmutableArray < Diagnostic > compilationDiagnostics , out ImmutableArray < Diagnostic > generatorDiagnostics , out GeneratorDriver generatorDriver , params string [ ] sources )
7778 where T : ISourceGenerator , new ( )
7879 {
7980 var compilation = CreateCompilation ( compiler , sources ) ;
8081
8182 var generator = new T ( ) ;
8283
83- var newCompilation = RunGenerators ( compilation , out generatorDiagnostics , new T ( ) ) ;
84+ var newCompilation = RunGenerators ( compilation , out generatorDiagnostics , out generatorDriver , generator ) ;
8485
8586 compilationDiagnostics = newCompilation . GetDiagnostics ( ) ;
8687
@@ -125,16 +126,10 @@ private static Microsoft.CodeAnalysis.Compilation CreateCompilation(EventBuilder
125126 options : new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary , deterministic : true ) ) ;
126127 }
127128
128- /// <summary>
129- /// Executes the source generators.
130- /// </summary>
131- /// <param name="compilation">The target compilation.</param>
132- /// <param name="diagnostics">The resulting diagnostics.</param>
133- /// <param name="generators">The generators to include in the compilation.</param>
134- /// <returns>The new compilation after the generators have executed.</returns>
135- private static Microsoft . CodeAnalysis . Compilation RunGenerators ( Microsoft . CodeAnalysis . Compilation compilation , out ImmutableArray < Diagnostic > diagnostics , params ISourceGenerator [ ] generators )
129+ private static Microsoft . CodeAnalysis . Compilation RunGenerators ( Microsoft . CodeAnalysis . Compilation compilation , out ImmutableArray < Diagnostic > diagnostics , out GeneratorDriver generatorDriver , params ISourceGenerator [ ] generators )
136130 {
137- CreateDriver ( compilation , generators ) . RunGeneratorsAndUpdateCompilation ( compilation , out var outputCompilation , out diagnostics ) ;
131+ generatorDriver = CreateDriver ( compilation , generators ) ;
132+ generatorDriver . RunGeneratorsAndUpdateCompilation ( compilation , out var outputCompilation , out diagnostics ) ;
138133 return outputCompilation ;
139134 }
140135
0 commit comments