Refactor
This commit is contained in:
50
SolutionParityChecker/SolutionParityChecker.cs
Normal file
50
SolutionParityChecker/SolutionParityChecker.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Microsoft.Build.Construction;
|
||||
|
||||
namespace SolutionParityChecker;
|
||||
|
||||
public static class SolutionParityChecker
|
||||
{
|
||||
public static void CompareSolutionAndCSharpProjects(
|
||||
string solutionFolderPath,
|
||||
string solutionFilePath
|
||||
) { }
|
||||
|
||||
public static string[] RetrieveAllCSharpProjectNamesFromFolder(string solutionFolderPath)
|
||||
{
|
||||
var csprojList = Directory.GetFiles(
|
||||
solutionFolderPath,
|
||||
"*.csproj",
|
||||
SearchOption.AllDirectories
|
||||
);
|
||||
csprojList = csprojList.Select(x => x.Replace(solutionFolderPath, "")).ToArray();
|
||||
return csprojList;
|
||||
}
|
||||
|
||||
public static SolutionFile? ParseSolutionFileFromPath(string solutionFilePath)
|
||||
{
|
||||
var solutionFile = SolutionFile.Parse(solutionFilePath);
|
||||
|
||||
return solutionFile;
|
||||
}
|
||||
|
||||
public static List<string> FindProjectsMissingFromSolution(
|
||||
string[] csprojList,
|
||||
SolutionFile solutionFile
|
||||
)
|
||||
{
|
||||
var projects = solutionFile.ProjectsInOrder;
|
||||
var projectsMissingFromSolution = new List<string>();
|
||||
|
||||
foreach (var project in csprojList)
|
||||
{
|
||||
var projectInSolution = projects.FirstOrDefault(x => x.RelativePath == project);
|
||||
|
||||
if (projectInSolution == null)
|
||||
{
|
||||
projectsMissingFromSolution.Add(project);
|
||||
}
|
||||
}
|
||||
|
||||
return projectsMissingFromSolution;
|
||||
}
|
||||
}
|
||||
13
SolutionParityChecker/SolutionParityChecker.csproj
Normal file
13
SolutionParityChecker/SolutionParityChecker.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Build" Version="17.7.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user