refactor
This commit is contained in:
@@ -15,40 +15,35 @@ public static class IntermediateMapper
|
|||||||
|
|
||||||
var rootFolders = vsSolution.SolutionFolders
|
var rootFolders = vsSolution.SolutionFolders
|
||||||
.Where(f => f.Parent is null)
|
.Where(f => f.Parent is null)
|
||||||
.Select(f => BuildFolderTree(f, solutionFilePath, vsSolution.SolutionFolders, vsSolution.SolutionProjects))
|
.Select(f => GetSlnFolderModel(f, solutionFilePath, vsSolution.SolutionFolders, vsSolution.SolutionProjects))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var rootProjects = vsSolution.SolutionProjects
|
||||||
|
.Where(p => p.Parent is null)
|
||||||
|
.Select(s => s.GetProjectModel(solutionFilePath))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var solutionModel = new IntermediateSolutionModel
|
var solutionModel = new IntermediateSolutionModel
|
||||||
{
|
{
|
||||||
Name = Path.GetFileName(solutionFilePath),
|
Name = Path.GetFileName(solutionFilePath),
|
||||||
FilePath = solutionFilePath,
|
FilePath = solutionFilePath,
|
||||||
Projects = vsSolution.SolutionProjects.Where(p => p.Parent is null).Select(s => new IntermediateProjectModel
|
Projects = rootProjects,
|
||||||
{
|
|
||||||
Model = s,
|
|
||||||
Id = s.Id,
|
|
||||||
FullFilePath = new DirectoryInfo(Path.Join(Path.GetDirectoryName(solutionFilePath), s.FilePath)).FullName
|
|
||||||
}).ToList(),
|
|
||||||
SolutionFolders = rootFolders
|
SolutionFolders = rootFolders
|
||||||
};
|
};
|
||||||
return solutionModel;
|
return solutionModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntermediateSlnFolderModel BuildFolderTree(SolutionFolderModel folder, string solutionFilePath,
|
private static IntermediateSlnFolderModel GetSlnFolderModel(SolutionFolderModel folder, string solutionFilePath,
|
||||||
IReadOnlyList<SolutionFolderModel> allSolutionFolders, IReadOnlyList<SolutionProjectModel> allSolutionProjects)
|
IReadOnlyList<SolutionFolderModel> allSolutionFolders, IReadOnlyList<SolutionProjectModel> allSolutionProjects)
|
||||||
{
|
{
|
||||||
var childFolders = allSolutionFolders
|
var childFolders = allSolutionFolders
|
||||||
.Where(f => f.Parent == folder)
|
.Where(f => f.Parent == folder)
|
||||||
.Select(f => BuildFolderTree(f, solutionFilePath, allSolutionFolders, allSolutionProjects))
|
.Select(f => GetSlnFolderModel(f, solutionFilePath, allSolutionFolders, allSolutionProjects))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var projectsInFolder = allSolutionProjects
|
var projectsInFolder = allSolutionProjects
|
||||||
.Where(p => p.Parent == folder)
|
.Where(p => p.Parent == folder)
|
||||||
.Select(s => new IntermediateProjectModel
|
.Select(s => s.GetProjectModel(solutionFilePath))
|
||||||
{
|
|
||||||
Model = s,
|
|
||||||
Id = s.Id,
|
|
||||||
FullFilePath = new DirectoryInfo(Path.Join(Path.GetDirectoryName(solutionFilePath), s.FilePath)).FullName
|
|
||||||
})
|
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var filesInFolder = folder.Files?
|
var filesInFolder = folder.Files?
|
||||||
@@ -67,4 +62,14 @@ public static class IntermediateMapper
|
|||||||
Files = filesInFolder
|
Files = filesInFolder
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IntermediateProjectModel GetProjectModel(this SolutionProjectModel project, string solutionFilePath)
|
||||||
|
{
|
||||||
|
return new IntermediateProjectModel
|
||||||
|
{
|
||||||
|
Model = project,
|
||||||
|
Id = project.Id,
|
||||||
|
FullFilePath = new DirectoryInfo(Path.Join(Path.GetDirectoryName(solutionFilePath), project.FilePath)).FullName
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Ardalis.GuardClauses;
|
|
||||||
using Microsoft.VisualStudio.SolutionPersistence.Model;
|
|
||||||
using Microsoft.VisualStudio.SolutionPersistence.Serializer;
|
|
||||||
|
|
||||||
namespace SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
namespace SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user