Skip to content

Commit

Permalink
use AsSourceGenerator instead of implementing both APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
mgravell committed Oct 5, 2023
1 parent ed8edfb commit bd6ab89
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

namespace Dapper.CodeAnalysis.Abstractions
{
public abstract class InterceptorGeneratorBase : DiagnosticAnalyzer, IIncrementalGenerator,
ISourceGenerator // for CSharpGeneratorDriver - see Roslyn #69906
public abstract class InterceptorGeneratorBase : DiagnosticAnalyzer, IIncrementalGenerator
{
public override void Initialize(AnalysisContext context)
{
Expand All @@ -15,10 +14,5 @@ public override void Initialize(AnalysisContext context)

/// <inheritdoc/>
public abstract void Initialize(IncrementalGeneratorInitializationContext context);

// for CSharpGeneratorDriver - see Roslyn #69906
void ISourceGenerator.Initialize(GeneratorInitializationContext context) { }
// for CSharpGeneratorDriver - see Roslyn #69906
void ISourceGenerator.Execute(GeneratorExecutionContext context) { }
}
}
4 changes: 2 additions & 2 deletions test/Dapper.AOT.Test/GeneratorTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected GeneratorTestBase(ITestOutputHelper? log)
[CallerMemberName] string? name = null,
string? fileName = null,
Action<T>? initializer = null
) where T : class, ISourceGenerator, new() // strictly we only need IIncrementalGenerator, but: see Roslyn #69906
) where T : class, IIncrementalGenerator, new()
{
void OutputDiagnostic(Diagnostic d)
{
Expand Down Expand Up @@ -67,7 +67,7 @@ void Output(string message, bool force = false)
ShowDiagnostics("Input code", inputCompilation, diagnosticsTo, "CS8795", "CS1701", "CS1702");

// Create the driver that will control the generation, passing in our generator
GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: RoslynTestHelpers.ParseOptionsLatestLangVer);
GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator.AsSourceGenerator() }, parseOptions: RoslynTestHelpers.ParseOptionsLatestLangVer);

// Run the generation pass
// (Note: the generator driver itself is immutable, and all calls return an updated version of the driver that you should use for subsequent calls)
Expand Down

0 comments on commit bd6ab89

Please sign in to comment.