private static int SortSolutionDirectory(string targetDirectory, IEnumerable <string> ignoredSolutionPatterns, bool saveChanges) { IEnumerable <string> filteredSolutions = Directory .EnumerateFiles(targetDirectory, "*.sln", SearchOption.AllDirectories) .Where(targetSolution => _ShouldProcessSolution(targetSolution, ignoredSolutionPatterns)); int solutionsModified = 0; Parallel.ForEach(filteredSolutions, targetSolution => { try { bool projectHadToBeSorted = SolutionSorter.ProcessSingleProject(targetSolution, saveChanges); if (projectHadToBeSorted) { Console.WriteLine($"Had to Sort: `{targetSolution}`"); solutionsModified++; } } catch (Exception ex) { Console.WriteLine($"Failed To Process Solution: `{targetSolution}`"); Console.Error.WriteLine(ex.ToString()); } } ); return(solutionsModified); }
private static int SortSolution(string targetSolution, bool saveChanges) { int modifiedStatus = 0; if (SolutionSorter.ProcessSingleProject(targetSolution, saveChanges)) { modifiedStatus++; } return(modifiedStatus); }