Skip to content

Commit 3693ec5

Browse files
committed
Limit search pattern and directory recursion
Narrow the scope of the search pattern to only include project files and limit directory recursion to 255 subdirectories to avoid infinite loops and subsequent `PathTooLongException`. May fix GH-4411.
1 parent 276336b commit 3693ec5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/GitVersion.Output/AssemblyInfo/ProjectFileUpdater.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,18 @@ private IEnumerable<IFileInfo> GetProjectFiles(AssemblyInfoContext context)
190190
}
191191
else
192192
{
193-
foreach (var item in fileSystem.Directory.EnumerateFiles(workingDirectory, "*", SearchOption.AllDirectories).Where(IsSupportedProjectFile))
193+
var options = new EnumerationOptions
194194
{
195-
var assemblyInfoFile = fileSystem.FileInfo.New(item);
196-
197-
yield return assemblyInfoFile;
195+
RecurseSubdirectories = true,
196+
MaxRecursionDepth = 255
197+
};
198+
var projectFiles = fileSystem.Directory
199+
.EnumerateFiles(workingDirectory, "*proj", options)
200+
.Where(IsSupportedProjectFile);
201+
202+
foreach (var projectFile in projectFiles)
203+
{
204+
yield return fileSystem.FileInfo.New(projectFile);
198205
}
199206
}
200207
}

0 commit comments

Comments
 (0)