in src/CodeGenerators/SettingsGen/BaseGenerator.cs [20:62]
public void Execute(GeneratorExecutionContext context)
{
if (context.SyntaxContextReceiver is not IParser<TSettingModel> parser)
{
return;
}
try
{
TSettingModel settings = parser.GetSettings();
bool shouldGen = ShouldGenerateFile(context, out AdditionalText? settingsFile);
if (!shouldGen)
{
context.ReportDiagnostic(Diagnostic.Create(DontGen, null));
return;
}
if (settingsFile == null)
{
throw new Exception("No file to compare given");
}
if (Comparer?.AreExistingSettingsEqual(settings, settingsFile) == true)
{
context.ReportDiagnostic(Diagnostic.Create(MatchingSettings, null));
return;
}
if (FileGenerator is null)
{
throw new Exception($"No file generator set for class {GetType().Name}");
}
context.ReportDiagnostic(Diagnostic.Create(WritingToFile, null, settingsFile.Path));
FileGenerator.GenerateFile(settings, settingsFile.Path);
}
catch (Exception ex)
{
context.ReportDiagnostic(Diagnostic.Create(FailedGeneration, null, ex.Message));
}
}