Fix serialization source gen with partial types

This fixes RMC compilation
This commit is contained in:
PJB3005
2025-03-22 06:09:48 +01:00
parent 4529a7569a
commit be0189748b
2 changed files with 13 additions and 6 deletions

View File

@@ -43,7 +43,7 @@ END TEMPLATE-->
### Bugfixes
*None yet*
* Fix serialization source generator breaking if a class has two partial locations.
### Other

View File

@@ -35,13 +35,20 @@ public class Generator : IIncrementalGenerator
.Where(static type => type != null);
initContext.RegisterSourceOutput(
dataDefinitions,
static (sourceContext, source) =>
dataDefinitions.Collect(),
static (sourceContext, sources) =>
{
// TODO: deduplicate based on name?
var (name, code) = source!.Value;
var done = new HashSet<string>();
sourceContext.AddSource(name, code);
foreach (var source in sources)
{
var (name, code) = source!.Value;
if (!done.Add(name))
continue;
sourceContext.AddSource(name, code);
}
}
);
}