public void Execute(GeneratorExecutionContext context) { if (context.SyntaxReceiver is SyntaxReceiver receiver) { var generator = new SourceTextGenerator(context.Compilation); foreach (var target in receiver.Targets.Values) { var sourceText = GenerateSourceText(generator, target); context.AddSource($"{target.Class.Identifier}.Generated.cs", sourceText); ReportGeneratorDiagnostics(context, generator); } ReportProgress(context, receiver.Targets.Values.Count); } }
private static void ReportGeneratorDiagnostics(GeneratorExecutionContext context, SourceTextGenerator generator) => generator.Diagnostics.ToList().ForEach(diagnostic => context.ReportDiagnostic(diagnostic));
private static SourceText GenerateSourceText(SourceTextGenerator generator, SystemClass target) => generator.Generate(target);