Rename and update logging

This commit is contained in:
Matt Parker
2025-08-13 19:14:32 +10:00
parent 54c672ee79
commit 0b30611aa7
4 changed files with 9 additions and 8 deletions

View File

@@ -0,0 +1,51 @@
using System.Diagnostics;
using Ardalis.GuardClauses;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.CodeAnalysis.MSBuild;
namespace SharpIDE.Application.Features.Analysis;
public static class RoslynAnalysis
{
public static async Task Analyse(string solutionFilePath)
{
Console.WriteLine($"RoslynAnalysis: Loading solution");
var timer = Stopwatch.StartNew();
var workspace = MSBuildWorkspace.Create();
workspace.WorkspaceFailed += (o, e) => throw new InvalidOperationException($"Workspace failed: {e.Diagnostic.Message}");
var solution = await workspace.OpenSolutionAsync(solutionFilePath, new Progress());
timer.Stop();
Console.WriteLine($"RoslynAnalysis: Solution loaded in {timer.ElapsedMilliseconds}ms");
Console.WriteLine();
foreach (var project in solution.Projects)
{
//Console.WriteLine($"Project: {project.Name}");
foreach (var document in project.Documents)
{
//Console.WriteLine($"Document: {document.Name}");
// var compilation = await project.GetCompilationAsync();
// Guard.Against.Null(compilation, nameof(compilation));
//
// // Get diagnostics (built-in or custom analyzers)
// var diagnostics = compilation.GetDiagnostics();
//
// foreach (var diagnostic in diagnostics)
// {
// Console.WriteLine(diagnostic);
// // Optionally run CodeFixProviders here
// }
// var syntaxTree = await document.GetSyntaxTreeAsync();
// var root = await syntaxTree!.GetRootAsync();
// var classifiedSpans = await Classifier.GetClassifiedSpansAsync(document, root.FullSpan);
// foreach (var span in classifiedSpans)
// {
// var classifiedSpan = root.GetText().GetSubText(span.TextSpan);
// Console.WriteLine($"{span.TextSpan}: {span.ClassificationType}");
// Console.WriteLine(classifiedSpan);
// }
}
}
}
}