public void Execute(SourceGeneratorContext context) { try { if (!(context.SyntaxReceiver is CandidateSyntaxReceiver receiver)) { return; } _genFactory.RunGeneration(context.Compilation, receiver.DeclaredTypes, generator => { generator.OnReportedDiagnostic += (_, diagnostic) => context.ReportDiagnostic(diagnostic); generator.OnGeneratedSource += (_, source) => context.AddSourceWithDebug(source); generator.GenerateFiles(); }); } catch (Exception e) { context.WriteException(e); } }