Skip to content

Commit 99a3138

Browse files
authored
Feature: return source generator with helper (#4)
* Feature: return source generator with helper * Add the missing documentation
1 parent a7ea6da commit 99a3138

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ReactiveMarbles.SourceGenerator.TestNuGetHelper/Compilation/SourceGeneratorUtility.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,22 @@ public SourceGeneratorUtility(Action<string> writeOutput)
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>
7474
/// <param name="sources">The source code files.</param>
75-
public void RunGenerator<T>(EventBuilderCompiler compiler, out ImmutableArray<Diagnostic> compilationDiagnostics, out ImmutableArray<Diagnostic> generatorDiagnostics, params string[] sources)
75+
/// <returns>The source generator instance.</returns>
76+
public T RunGenerator<T>(EventBuilderCompiler compiler, out ImmutableArray<Diagnostic> compilationDiagnostics, out ImmutableArray<Diagnostic> generatorDiagnostics, params string[] sources)
7677
where T : ISourceGenerator, new()
7778
{
7879
var compilation = CreateCompilation(compiler, sources);
7980

81+
var generator = new T();
82+
8083
var newCompilation = RunGenerators(compilation, out generatorDiagnostics, new T());
8184

8285
compilationDiagnostics = newCompilation.GetDiagnostics();
8386

8487
ShouldHaveNoCompilerDiagnosticsWarningOrAbove(_writeOutput, newCompilation, compilationDiagnostics);
8588
ShouldHaveNoCompilerDiagnosticsWarningOrAbove(_writeOutput, compilation, generatorDiagnostics);
89+
90+
return generator;
8691
}
8792

8893
private static void ShouldHaveNoCompilerDiagnosticsWarningOrAbove(Action<string> output, Microsoft.CodeAnalysis.Compilation compilation, IEnumerable<Diagnostic> diagnostics)

0 commit comments

Comments
 (0)