Skip to content

Commit

Permalink
fix multiple generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed May 31, 2024
1 parent b8abf2c commit 057a12d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Snap.Hutao.SourceGeneration</id>
<version>1.0.10</version>
<version>1.0.11</version>
<authors>DGP Studio</authors>
<developmentDependency>true</developmentDependency>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ internal class XamlUnloadObjectOverrideGenerator : IIncrementalGenerator

public void Initialize(IncrementalGeneratorInitializationContext context)
{
IncrementalValuesProvider<GeneratorSyntaxContext3> inheritClasses = context.SyntaxProvider
IncrementalValueProvider<ImmutableArray<GeneratorSyntaxContext3>> inheritClasses = context.SyntaxProvider
.CreateSyntaxProvider(FilterClassWithBaseList, ScopedPageInheritClass)
.Where(GeneratorSyntaxContext3.NotNull);
.Where(GeneratorSyntaxContext3.NotNull)
.Collect();

context.RegisterSourceOutput(inheritClasses, GenerateUnloadObjectOverrideImplementation);
context.RegisterSourceOutput(inheritClasses, GenerateUnloadObjectOverrideImplementations);
}

private static bool FilterClassWithBaseList(SyntaxNode node, CancellationToken token)
Expand All @@ -42,6 +43,14 @@ private static GeneratorSyntaxContext3 ScopedPageInheritClass(GeneratorSyntaxCon
return default;
}

private static void GenerateUnloadObjectOverrideImplementations(SourceProductionContext production, ImmutableArray<GeneratorSyntaxContext3> context3s)
{
foreach (GeneratorSyntaxContext3 context3 in context3s.DistinctBy(c => c.Symbol.ToDisplayString()))
{
GenerateUnloadObjectOverrideImplementation(production, context3);
}
}

private static void GenerateUnloadObjectOverrideImplementation(SourceProductionContext production, GeneratorSyntaxContext3 context3)
{
StringBuilder sourceBuilder = new StringBuilder().Append($$"""
Expand Down

0 comments on commit 057a12d

Please sign in to comment.