forked from dotnet/winforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure source paths leave 40 characters for root (dotnet#11835)
The default path for VS is in the user directory, which ends up being something like `C:\Users\jkuhne\source\repos\winforms`. Recent paths make the repo impossible to sync. I've added a test that reserves 40 characters for the repro root path and moved files out of subdirectories that violated that. A longer follow up is to see if we can pick some type names that aren't so long. Additionally we should try to up this check to 50 characters- which would require more renaming.
- Loading branch information
1 parent
4c8f625
commit 7006c1c
Showing
29 changed files
with
44 additions
and
10 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/PathLengthTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using FluentAssertions; | ||
using System.IO.Enumeration; | ||
|
||
namespace System.Tests; | ||
|
||
public class PathLengthTests | ||
{ | ||
[Fact] | ||
public void RepoPathsLeaveRoomForRoot() | ||
{ | ||
string currentPath = typeof(PathLengthTests).Assembly.Location; | ||
currentPath = Path.GetFullPath(@"..\..\..\..\..\..\src", currentPath); | ||
Directory.Exists(currentPath).Should().BeTrue(); | ||
|
||
// Current path will be something like C:\Users\jkuhne\source\repos\winforms\src (41 chars, 38 without src). | ||
// We want to reserve 40 characters of the path length for everything past src. | ||
int currentRootLength = currentPath.Length - "src".Length; | ||
|
||
const int MaxRootLength = 40; | ||
|
||
int maxLength = 260 - (currentRootLength > MaxRootLength | ||
? MaxRootLength | ||
: MaxRootLength + (MaxRootLength - currentRootLength)); | ||
|
||
FileSystemEnumerable<string> enumerable = new( | ||
currentPath, | ||
(ref FileSystemEntry entry) => entry.ToFullPath(), | ||
new EnumerationOptions() { RecurseSubdirectories = true }) | ||
{ | ||
ShouldIncludePredicate = (ref FileSystemEntry entry) => | ||
// Directory doesn't contain a trailing slash | ||
entry.Directory.Length + entry.FileName.Length > maxLength | ||
}; | ||
|
||
enumerable.Should().BeEmpty(); | ||
} | ||
} |