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.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<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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user