-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Support long module path #33505
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
Support long module path #33505
Changes from 4 commits
638594b
ff306e0
20187cf
ed89f18
0b1c57e
969b96b
c3db3e6
e26b516
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Runtime.InteropServices; | ||
| using Microsoft.DotNet.RemoteExecutor; | ||
| using Xunit; | ||
|
|
||
|
|
@@ -28,6 +30,61 @@ public void TestModuleProperties() | |
| } | ||
| } | ||
|
|
||
| [ConditionalFact(nameof(IsProcessElevated))] | ||
| [PlatformSpecific(TestPlatforms.Windows)] | ||
| public void TestModuleLongPath() | ||
| { | ||
| // // Metadata version: v4.0.30319 | ||
| // .assembly Test | ||
| // { | ||
| // .ver 0:0:0:0 | ||
| // } | ||
| // .module Test.dll | ||
| // // MVID: {48E60D10-353B-45DC-AA09-3A1E6B0FD382} | ||
| // .imagebase 0x00400000 | ||
| // .file alignment 0x00000200 | ||
| // .stackreserve 0x00100000 | ||
| // .subsystem 0x0003 // WINDOWS_CUI | ||
| // .corflags 0x00000001 // ILONLY | ||
| byte[] assemblyImage = Convert.FromBase64String( | ||
|
||
| "TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFt" + | ||
| "IGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAECAJyj7l8AA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vcmVlLmRsbAAAAAAA/yUAIEAA" + | ||
| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + | ||
| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAMAAAAgDEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + | ||
| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + | ||
| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + | ||
| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + | ||
| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + | ||
| "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + | ||
| "AAAAAAAA" | ||
| ); | ||
|
|
||
| string libraryDirectory = GetTestFilePath(); | ||
| Directory.CreateDirectory(libraryDirectory); | ||
| string libraryPath = Path.Combine(libraryDirectory, new string('_', 250) + ".dll"); | ||
| Assert.True(libraryPath.Length > 260); | ||
| File.WriteAllBytes(libraryPath, assemblyImage); | ||
|
|
||
| IntPtr library = NativeLibrary.Load(libraryPath); | ||
| Assert.True(library != IntPtr.Zero); | ||
| try | ||
| { | ||
| Assert.Contains(Process.GetCurrentProcess().Modules.Cast<ProcessModule>(), module => module.FileName == libraryPath); | ||
| } | ||
| finally | ||
| { | ||
| NativeLibrary.Free(library); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Modules_Get_ContainsHostFileName() | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of
toReturn- can't you do:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danmosemsft This would call
Returnmultiple timeswhenRent` throws an exception.It would be fine to write it this way if the
Returnis not inside finally block (ie we let GC take care of collecting the buffer when exception is thrown).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes - tricky. might be worth a comment.