Skip to content

Fix incremental generator in deterministic key file #77553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,11 @@ void writeGenerators()
writer.WriteArrayStart();
foreach (var generator in generators)
{
object obj = generator is IncrementalGeneratorWrapper w
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? w.Generator
: generator;
cancellationToken.ThrowIfCancellationRequested();
WriteType(writer, generator.GetType());
WriteType(writer, obj.GetType());
}
writer.WriteArrayEnd();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@ private sealed class Generator2 : ISourceGenerator

public void Initialize(GeneratorInitializationContext context) => throw new NotImplementedException();
}

private sealed class Generator3 : IIncrementalGenerator
{
public void Initialize(IncrementalGeneratorInitializationContext context) => throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,8 @@ public void Generators()
var array = GetGeneratorValues(
CreateCompilation(Array.Empty<SyntaxTree>()),
new Generator(),
new Generator2());
new Generator2(),
new Generator3().AsSourceGenerator());

var assembly = typeof(Generator).Assembly;
var expected = @$"
Expand All @@ -817,6 +818,11 @@ public void Generators()
""fullName"": ""{typeof(Generator2).FullName}"",
""assemblyName"": ""{assembly.FullName}"",
""mvid"": ""{DeterministicKeyBuilder.GetGuidValue(assembly.ManifestModule.ModuleVersionId)}""
}},
{{
""fullName"": ""{typeof(Generator3).FullName}"",
""assemblyName"": ""{assembly.FullName}"",
""mvid"": ""{DeterministicKeyBuilder.GetGuidValue(assembly.ManifestModule.ModuleVersionId)}""
}}
]
";
Expand Down