Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable long paths on Tasks #3503

Merged
merged 3 commits into from Dec 11, 2018

Conversation

ccastanedaucf
Copy link
Contributor

@ccastanedaucf ccastanedaucf commented Jul 11, 2018

Slowly working on this whenever there's time. So far this covers 2/3 tasks.

var buffer = new StringBuilder();

// Try increased buffer sizes if on longpath-enabled Windows
for (int bufferSize = initialSize; hasNoMaxPath && isBufferTooSmall; bufferSize *= 2)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly I'm not sure if there's a better way to do this with the way the native API is designed. There's no way to get the required buffer size from the function.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683197(v=vs.85).aspx

@@ -1241,6 +1241,48 @@ internal static int GetParentProcessId(int processId)
return myChildren;
}

internal static string GetModuleFileName(string fileName)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed this execution path isn't covered at all by tests in StripTypeLibNumberFromPath, what would be a good way to test this?

@@ -115,9 +115,8 @@ public FileDirInfo(string filename)
//
// Also, when not under debugger (!) it will give error == 3 for path too long. Make that consistently throw instead.
if ((error == 2 /* ERROR_FILE_NOT_FOUND */|| error == 3 /* ERROR_PATH_NOT_FOUND */)
&& _filename.Length <= NativeMethodsShared.MAX_PATH)
&& _filename.Length <= (int)NativeMethodsShared.OSMaxPathLimit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum value, maybe we should just split up OSMaxPathLimit into a bool and int value if the only real case to watch for is Windows + 260.

@@ -48,7 +48,7 @@ internal static class NativeMethodsShared
/// <summary>
/// Default buffer size to use when dealing with the Windows API.
/// </summary>
internal const int MAX_PATH = 260;
private const int MAX_PATH = 260;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call this WindowsLegacyMaxPath

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually was my original name for it #3406 (comment)

{
SetOSMaxPathLimit();
SetMaxPath();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put the ifdef inside SetMaxPath, to have all initialization logic in one place.

@@ -101,6 +101,9 @@ public FileDirInfo(string filename)
{
if (NativeMethodsShared.IsWindows)
{
// GetFileAttributesEx() will fail with long paths if not normalized
_filename = NativeMethodsShared.HasMaxPath ? _filename : FileUtilities.NormalizePath(_filename);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging by the comment, shouldn't the path get normalized only when there are max path limits?

@ccastanedaucf ccastanedaucf changed the title [WIP] Enable long paths on Tasks Enable long paths on Tasks Dec 3, 2018
@ccastanedaucf
Copy link
Contributor Author

So this passes locally and I'm not seeing how a change in Tasks would have any effect on ProjectGraph cycle detection.

Error message
System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary.
Stack trace
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at Microsoft.Build.Graph.ProjectGraph.DetectCycles(ProjectGraphNode node, Dictionary`2 nodeState, ProjectCollection projectCollection, PropertyDictionary`1 globalProperties) in /_/src/Build/Graph/ProjectGraph.cs:line 526
   at Microsoft.Build.Graph.ProjectGraph.DetectCycles(ProjectGraphNode node, Dictionary`2 nodeState, ProjectCollection projectCollection, PropertyDictionary`1 globalProperties) in /_/src/Build/Graph/ProjectGraph.cs:line 553
   at Microsoft.Build.Graph.ProjectGraph.DetectCycles(ProjectGraphNode node, Dictionary`2 nodeState, ProjectCollection projectCollection, PropertyDictionary`1 globalProperties) in /_/src/Build/Graph/ProjectGraph.cs:line 553
   at Microsoft.Build.Graph.ProjectGraph..ctor(IEnumerable`1 entryPoints, ProjectCollection projectCollection, ProjectInstanceFactoryFunc projectInstanceFactory) in /_/src/Build/Graph/ProjectGraph.cs:line 226
   at Microsoft.Build.Graph.ProjectGraph..ctor(String entryProjectFile) in /_/src/Build/Graph/ProjectGraph.cs:line 51
   at Microsoft.Build.Graph.UnitTests.ProjectGraphTests.ConstructWithConvergingProperties() in D:\a\1\s\src\Build.UnitTests\Graph\ProjectGraph_Tests.cs:line 279

@rainersigwald
Copy link
Member

I agree, so I reran it and it passed, which . . . ok, I guess?

@ccastanedaucf
Copy link
Contributor Author

Just talked to @yash256 and @cdmihai it seems to be a flaky test that needs fixing.

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. I'd like to get #3987 in first, since it's a higher-pri change to ResolveCOMReference which might conflict if we anger the merge, so let's hold off until next week. But exciting!

@rainersigwald
Copy link
Member

Closing/reopening to retest after that other PR went in. If it passes I'm good to go on this.

@ccastanedaucf ccastanedaucf merged commit 88b80b5 into dotnet:master Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants