add stuff
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
namespace SharpIDE.Application.Features.SolutionDiscovery;
|
||||||
|
|
||||||
|
public class Folder
|
||||||
|
{
|
||||||
|
public required string Name { get; set; }
|
||||||
|
public List<Folder> Folders { get; set; } = [];
|
||||||
|
public List<MyFile> Files { get; set; } = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MyFile
|
||||||
|
{
|
||||||
|
public required string Name { get; set; }
|
||||||
|
}
|
||||||
@@ -1,12 +1,40 @@
|
|||||||
using Microsoft.Build.Construction;
|
using Microsoft.Build.Construction;
|
||||||
|
using Microsoft.Build.Evaluation;
|
||||||
|
using Microsoft.Build.Globbing;
|
||||||
|
|
||||||
namespace SharpIDE.Application.Features.SolutionDiscovery;
|
namespace SharpIDE.Application.Features.SolutionDiscovery;
|
||||||
|
|
||||||
public static class GetNodesInSolution
|
public static class GetNodesInSolution
|
||||||
{
|
{
|
||||||
|
private static readonly ProjectCollection _projectCollection = new();
|
||||||
public static SolutionFile? ParseSolutionFileFromPath(string solutionFilePath)
|
public static SolutionFile? ParseSolutionFileFromPath(string solutionFilePath)
|
||||||
{
|
{
|
||||||
var solutionFile = SolutionFile.Parse(solutionFilePath);
|
var solutionFile = SolutionFile.Parse(solutionFilePath);
|
||||||
return solutionFile;
|
return solutionFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<ProjectRootElement> 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<FileInfo> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
@using Microsoft.Build.Construction
|
@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
|
@using SharpIDE.Application.Features.SolutionDiscovery
|
||||||
|
|
||||||
<MudText>Welcome to a new Photino Blazor app!</MudText>
|
<MudText>Welcome to a new Photino Blazor app!</MudText>
|
||||||
@@ -21,6 +25,7 @@
|
|||||||
|
|
||||||
private SolutionFile _solutionFile = null!;
|
private SolutionFile _solutionFile = null!;
|
||||||
private List<ProjectInSolution> _rootNodes = [];
|
private List<ProjectInSolution> _rootNodes = [];
|
||||||
|
private Dictionary<string, List<Folder>> _folders = new();
|
||||||
|
|
||||||
private RenderFragment GetProjectFragment(ProjectInSolution project) =>
|
private RenderFragment GetProjectFragment(ProjectInSolution project) =>
|
||||||
@<text>
|
@<text>
|
||||||
@@ -29,9 +34,19 @@
|
|||||||
{
|
{
|
||||||
@GetProjectFragment(child)
|
@GetProjectFragment(child)
|
||||||
}
|
}
|
||||||
|
@GetFolderFragment(project)
|
||||||
</MudTreeViewItem>
|
</MudTreeViewItem>
|
||||||
</text>;
|
</text>;
|
||||||
|
|
||||||
|
private RenderFragment GetFolderFragment(ProjectInSolution project) =>
|
||||||
|
@<text>
|
||||||
|
@foreach (var folder in _folders.GetValueOrDefault(project.ProjectGuid, []))
|
||||||
|
{
|
||||||
|
<MudTreeViewItem Value="folder" Text="@folder.Name">
|
||||||
|
</MudTreeViewItem>
|
||||||
|
}
|
||||||
|
</text>;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
var solutionFile = GetNodesInSolution.ParseSolutionFileFromPath("D:/matth/Documents/Git/amazon/ClientPortal.sln");
|
var solutionFile = GetNodesInSolution.ParseSolutionFileFromPath("D:/matth/Documents/Git/amazon/ClientPortal.sln");
|
||||||
@@ -39,7 +54,8 @@
|
|||||||
_solutionFile = solutionFile;
|
_solutionFile = solutionFile;
|
||||||
var rootNodes = solutionFile.ProjectsByGuid.Values.Where(p => p.ParentProjectGuid == null).OrderBy(s => s.ProjectName).ToList();
|
var rootNodes = solutionFile.ProjectsByGuid.Values.Where(p => p.ParentProjectGuid == null).OrderBy(s => s.ProjectName).ToList();
|
||||||
_rootNodes = rootNodes;
|
_rootNodes = rootNodes;
|
||||||
Console.WriteLine();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user