diff --git a/src/SharpIDE.Application/Features/SolutionDiscovery/Folder.cs b/src/SharpIDE.Application/Features/SolutionDiscovery/Folder.cs new file mode 100644 index 0000000..cf8f5a7 --- /dev/null +++ b/src/SharpIDE.Application/Features/SolutionDiscovery/Folder.cs @@ -0,0 +1,13 @@ +namespace SharpIDE.Application.Features.SolutionDiscovery; + +public class Folder +{ + public required string Name { get; set; } + public List Folders { get; set; } = []; + public List Files { get; set; } = []; +} + +public class MyFile +{ + public required string Name { get; set; } +} diff --git a/src/SharpIDE.Application/Features/SolutionDiscovery/GetNodesInSolution.cs b/src/SharpIDE.Application/Features/SolutionDiscovery/GetNodesInSolution.cs index b7995aa..03e9083 100644 --- a/src/SharpIDE.Application/Features/SolutionDiscovery/GetNodesInSolution.cs +++ b/src/SharpIDE.Application/Features/SolutionDiscovery/GetNodesInSolution.cs @@ -1,12 +1,40 @@ using Microsoft.Build.Construction; +using Microsoft.Build.Evaluation; +using Microsoft.Build.Globbing; namespace SharpIDE.Application.Features.SolutionDiscovery; public static class GetNodesInSolution { + private static readonly ProjectCollection _projectCollection = new(); public static SolutionFile? ParseSolutionFileFromPath(string solutionFilePath) { var solutionFile = SolutionFile.Parse(solutionFilePath); return solutionFile; } + + public static List GetCSharpProjectObjectsFromSolutionFile(SolutionFile solutionFile) + { + var projectList = solutionFile + .ProjectsByGuid.Where(x => x.Value.ProjectType == SolutionProjectType.KnownToBeMSBuildFormat) + .Select(s => ProjectRootElement.Open(s.Value.AbsolutePath)) + .ToList(); + + return projectList; + } + + public static List GetFilesInProject(string projectPath) + { + var project = _projectCollection.LoadProject(projectPath); + var compositeGlob = new CompositeGlob(project.GetAllGlobs().Select(s => s.MsBuildGlob)); + var directory = new DirectoryInfo(Path.GetDirectoryName(projectPath)!); + var files = directory.EnumerateFiles("*", SearchOption.AllDirectories) + .Where(f => + { + var relativeDirectory = Path.GetRelativePath(directory.FullName, f.FullName); + return compositeGlob.IsMatch(relativeDirectory); + }) + .ToList(); + return files; + } } diff --git a/src/SharpIDE.Photino/Pages/Home.razor b/src/SharpIDE.Photino/Pages/Home.razor index 8951c04..3d031c4 100644 --- a/src/SharpIDE.Photino/Pages/Home.razor +++ b/src/SharpIDE.Photino/Pages/Home.razor @@ -1,5 +1,9 @@ @page "/" @using Microsoft.Build.Construction +@using Microsoft.Build.Evaluation +@using Microsoft.Build.Execution +@using Microsoft.Build.Globbing +@using Microsoft.Build.Globbing.Extensions @using SharpIDE.Application.Features.SolutionDiscovery Welcome to a new Photino Blazor app! @@ -21,6 +25,7 @@ private SolutionFile _solutionFile = null!; private List _rootNodes = []; + private Dictionary> _folders = new(); private RenderFragment GetProjectFragment(ProjectInSolution project) => @ @@ -29,9 +34,19 @@ { @GetProjectFragment(child) } + @GetFolderFragment(project) ; + private RenderFragment GetFolderFragment(ProjectInSolution project) => + @ + @foreach (var folder in _folders.GetValueOrDefault(project.ProjectGuid, [])) + { + + + } + ; + protected override async Task OnInitializedAsync() { var solutionFile = GetNodesInSolution.ParseSolutionFileFromPath("D:/matth/Documents/Git/amazon/ClientPortal.sln"); @@ -39,7 +54,8 @@ _solutionFile = solutionFile; var rootNodes = solutionFile.ProjectsByGuid.Values.Where(p => p.ParentProjectGuid == null).OrderBy(s => s.ProjectName).ToList(); _rootNodes = rootNodes; - Console.WriteLine(); + + } }