@@ -125,6 +125,73 @@ public T RunGenerator<T>(EventBuilderCompiler compiler, out ImmutableArray<Diagn
125125 return generator ;
126126 }
127127
128+ /// <summary>
129+ /// Runs the generator.
130+ /// </summary>
131+ /// <param name="compiler">The compiler.</param>
132+ /// <param name="generator">The source generator instance.</param>
133+ /// <param name="compilationDiagnostics">The diagnostics which are produced from the compiler.</param>
134+ /// <param name="generatorDiagnostics">The diagnostics which are produced from the generator.</param>
135+ /// <param name="generatorDriver">Output value for the driver.</param>
136+ /// <param name="sources">The source code files.</param>
137+ /// <returns>The returned source generator instance.</returns>
138+ public ISourceGenerator RunGeneratorInstance ( EventBuilderCompiler compiler , ISourceGenerator generator , out ImmutableArray < Diagnostic > compilationDiagnostics , out ImmutableArray < Diagnostic > generatorDiagnostics , out GeneratorDriver generatorDriver , params string [ ] sources ) =>
139+ RunGeneratorInstance ( compiler , generator , out compilationDiagnostics , out generatorDiagnostics , out generatorDriver , out _ , out _ , sources ) ;
140+
141+ /// <summary>
142+ /// Runs the generator.
143+ /// </summary>
144+ /// <param name="compiler">The compiler.</param>
145+ /// <param name="generator">The source generator instance.</param>
146+ /// <param name="compilationDiagnostics">The diagnostics which are produced from the compiler.</param>
147+ /// <param name="generatorDiagnostics">The diagnostics which are produced from the generator.</param>
148+ /// <param name="generatorDriver">Output value for the driver.</param>
149+ /// <param name="sources">The source code files.</param>
150+ /// <returns>The returned source generator instance.</returns>
151+ public ISourceGenerator RunGeneratorInstance ( EventBuilderCompiler compiler , ISourceGenerator generator , out ImmutableArray < Diagnostic > compilationDiagnostics , out ImmutableArray < Diagnostic > generatorDiagnostics , out GeneratorDriver generatorDriver , params ( string FileName , string Source ) [ ] sources ) =>
152+ RunGeneratorInstance ( compiler , generator , out compilationDiagnostics , out generatorDiagnostics , out generatorDriver , out _ , out _ , sources ) ;
153+
154+ /// <summary>
155+ /// Runs the generator.
156+ /// </summary>
157+ /// <param name="compiler">The compiler.</param>
158+ /// <param name="generator">The source generator instance.</param>
159+ /// <param name="compilationDiagnostics">The diagnostics which are produced from the compiler.</param>
160+ /// <param name="generatorDiagnostics">The diagnostics which are produced from the generator.</param>
161+ /// <param name="generatorDriver">Output value for the driver.</param>
162+ /// <param name="beforeCompilation">The compilation before the generator has run.</param>
163+ /// <param name="afterGeneratorCompilation">The compilation after the generator has run.</param>
164+ /// <param name="sources">The source code files.</param>
165+ /// <returns>The returned source generator instance.</returns>
166+ public ISourceGenerator RunGeneratorInstance ( EventBuilderCompiler compiler , ISourceGenerator generator , out ImmutableArray < Diagnostic > compilationDiagnostics , out ImmutableArray < Diagnostic > generatorDiagnostics , out GeneratorDriver generatorDriver , out Microsoft . CodeAnalysis . Compilation beforeCompilation , out Microsoft . CodeAnalysis . Compilation afterGeneratorCompilation , params string [ ] sources ) =>
167+ RunGeneratorInstance ( compiler , generator , out compilationDiagnostics , out generatorDiagnostics , out generatorDriver , out beforeCompilation , out afterGeneratorCompilation , sources . Select ( x => ( FileName : "Unknown File" , Source : x ) ) . ToArray ( ) ) ;
168+
169+ /// <summary>
170+ /// Runs the generator.
171+ /// </summary>
172+ /// <param name="compiler">The compiler.</param>
173+ /// <param name="generator">The source generator instance.</param>
174+ /// <param name="compilationDiagnostics">The diagnostics which are produced from the compiler.</param>
175+ /// <param name="generatorDiagnostics">The diagnostics which are produced from the generator.</param>
176+ /// <param name="generatorDriver">Output value for the driver.</param>
177+ /// <param name="beforeCompilation">The compilation before the generator has run.</param>
178+ /// <param name="afterGeneratorCompilation">The compilation after the generator has run.</param>
179+ /// <param name="sources">The source code files.</param>
180+ /// <returns>The returned source generator instance.</returns>
181+ public ISourceGenerator RunGeneratorInstance ( EventBuilderCompiler compiler , ISourceGenerator generator , 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 )
182+ {
183+ beforeCompilation = CreateCompilation ( compiler , sources ) ;
184+
185+ afterGeneratorCompilation = RunGenerators ( beforeCompilation , out generatorDiagnostics , out generatorDriver , generator ) ;
186+
187+ compilationDiagnostics = afterGeneratorCompilation . GetDiagnostics ( ) ;
188+
189+ ShouldHaveNoCompilerDiagnosticsWarningOrAbove ( _writeOutput , afterGeneratorCompilation , compilationDiagnostics ) ;
190+ ShouldHaveNoCompilerDiagnosticsWarningOrAbove ( _writeOutput , beforeCompilation , generatorDiagnostics ) ;
191+
192+ return generator ;
193+ }
194+
128195 /// <summary>
129196 /// Runs the generator.
130197 /// </summary>
0 commit comments