public void ApplyReport(AnnotationReport report) { var originalContent = _fileManager.ReadAllText(report.CloudFormationTemplatePath); var templateDirectory = _directoryManager.GetDirectoryName(report.CloudFormationTemplatePath); var relativeProjectUri = _directoryManager.GetRelativePath(templateDirectory, report.ProjectRootDirectory); if (string.IsNullOrEmpty(originalContent)) { CreateNewTemplate(); } else { _jsonWriter.Parse(originalContent); } var processedLambdaFunctions = new HashSet <string>(); foreach (var lambdaFunction in report.LambdaFunctions) { if (!ShouldProcessLambdaFunction(lambdaFunction)) { continue; } ProcessLambdaFunction(lambdaFunction, relativeProjectUri); processedLambdaFunctions.Add(lambdaFunction.Name); } RemoveOrphanedLambdaFunctions(processedLambdaFunctions); var json = _jsonWriter.GetPrettyJson(); _fileManager.WriteAllText(report.CloudFormationTemplatePath, json); _diagnosticReporter.Report(Diagnostic.Create(DiagnosticDescriptors.CodeGeneration, Location.None, $"{report.CloudFormationTemplatePath}", json)); }