diff --git a/src/SharpIDE.Application/Features/SolutionDiscovery/RoslynTest.cs b/src/SharpIDE.Application/Features/SolutionDiscovery/RoslynTest.cs new file mode 100644 index 0000000..e26e49a --- /dev/null +++ b/src/SharpIDE.Application/Features/SolutionDiscovery/RoslynTest.cs @@ -0,0 +1,40 @@ +using System.Diagnostics; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Classification; +using Microsoft.CodeAnalysis.MSBuild; + +namespace SharpIDE.Application.Features.SolutionDiscovery; + +public static class RoslynTest +{ + public static async Task Analyse(string solutionFilePath) + { + + + var workspace = MSBuildWorkspace.Create(); + var timer = Stopwatch.StartNew(); + var solution = await workspace.OpenSolutionAsync(solutionFilePath); + timer.Stop(); + Console.WriteLine($"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 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); + } + } + } + + } +} diff --git a/src/SharpIDE.Application/SharpIDE.Application.csproj b/src/SharpIDE.Application/SharpIDE.Application.csproj index 464aa47..0c35acb 100644 --- a/src/SharpIDE.Application/SharpIDE.Application.csproj +++ b/src/SharpIDE.Application/SharpIDE.Application.csproj @@ -9,6 +9,8 @@ + + diff --git a/src/SharpIDE.Photino/Components/SolutionExplorer.razor b/src/SharpIDE.Photino/Components/SolutionExplorer.razor index 9d7b408..4e28426 100644 --- a/src/SharpIDE.Photino/Components/SolutionExplorer.razor +++ b/src/SharpIDE.Photino/Components/SolutionExplorer.razor @@ -53,12 +53,12 @@ protected override async Task OnInitializedAsync() { - await Task.Run(() => LoadSolution("D:/matth/Documents/Git/amazon/ClientPortal.sln")); + await Task.Run(() => LoadSolution("C:/Users/Matthew/Documents/Git/amazon/ClientPortal.sln")); } private void LoadSolution(string solutionPath) { - var solutionFile = GetNodesInSolution.ParseSolutionFileFromPath("D:/matth/Documents/Git/amazon/ClientPortal.sln"); + var solutionFile = GetNodesInSolution.ParseSolutionFileFromPath("C:/Users/Matthew/Documents/Git/amazon/ClientPortal.sln"); ArgumentNullException.ThrowIfNull(solutionFile); _solutionFile = solutionFile; var rootNodes = solutionFile.ProjectsByGuid.Values.Where(p => p.ParentProjectGuid == null).OrderBy(s => s.ProjectName).ToList(); diff --git a/src/SharpIDE.Photino/Pages/Home.razor b/src/SharpIDE.Photino/Pages/Home.razor index e82cc8c..6413d90 100644 --- a/src/SharpIDE.Photino/Pages/Home.razor +++ b/src/SharpIDE.Photino/Pages/Home.razor @@ -1,8 +1,12 @@ @page "/" +@using SharpIDE.Application.Features.SolutionDiscovery - + @code { - + protected override async Task OnInitializedAsync() + { + await RoslynTest.Analyse("C:/Users/Matthew/Documents/Git/StatusApp/StatusApp.sln"); + } }