// Analysis public static string GetMessage(Compilation compilation, DiagnosticAnalyzer[] analyzers, Diagnostic[] diagnostics) { var builder = new HierarchicalStringBuilder(); using (builder.AppendTitle("Analysis result:")) { builder.AppendObject(compilation); builder.AppendObject(analyzers); builder.AppendObject(diagnostics); } return(builder.ToString()); }
// Generation public static string GetMessage(ISourceGenerator generator, Compilation compilation, GeneratedSourceResult[] sources, Diagnostic[] diagnostics, Exception?exception) { var builder = new HierarchicalStringBuilder(); using (builder.AppendTitle("Generation result:")) { builder.AppendLine("Generator: {0}", generator.GetType().Name); builder.AppendObject(compilation); builder.AppendObject(diagnostics); builder.AppendObject(exception); builder.AppendObject(sources); } return(builder.ToString()); }
// Render/Text/Hierarchical public static string RenderToHierarchicalText(this ProjectArchNode project) { var builder = new HierarchicalStringBuilder(); builder.AppendObject(project); return(builder.ToString()); }
private static void AppendObject(this HierarchicalStringBuilder builder, NamespaceArchNode @namespace) { using var scope = builder.AppendSection("Namespace: {0}", @namespace.Name); foreach (var group in @namespace.Groups) { builder.AppendObject(group); } }
private static void AppendObject(this HierarchicalStringBuilder builder, ModuleArchNode module) { using var scope = builder.AppendSection("Module: {0}", module.Name); foreach (var @namespace in module.Namespaces) { builder.AppendObject(@namespace); } }
private static void AppendObject(this HierarchicalStringBuilder builder, ProjectArchNode project) { using (builder.AppendTitle("Project: {0}", project.Name)) { foreach (var module in project.Modules) { builder.AppendObject(module); } } }