Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{3742D5F8-5C86-49FD-BAEA-050742CCEB7A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LongPath", "tests\LongPath\LongPath.csproj", "{C67553AE-F09B-407D-AD3E-D61950E06BE8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry", "..\Microsoft.Win32.Registry\ref\Microsoft.Win32.Registry.csproj", "{AA583AE2-BE26-4AA4-845F-916133916B7D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.Registry", "..\Microsoft.Win32.Registry\src\Microsoft.Win32.Registry.csproj", "{E5AE4EB3-DB23-4F33-858B-63B68A60F7F1}"
Expand Down Expand Up @@ -50,6 +52,7 @@ EndProject
Global
GlobalSection(NestedProjects) = preSolution
{3742D5F8-5C86-49FD-BAEA-050742CCEB7A} = {05C87914-711A-4589-9672-8169DB6A6BA4}
{C67553AE-F09B-407D-AD3E-D61950E06BE8} = {05C87914-711A-4589-9672-8169DB6A6BA4}
{ABA61FEF-EB06-441D-9D3D-F25FFC7CD83D} = {05C87914-711A-4589-9672-8169DB6A6BA4}
{AA583AE2-BE26-4AA4-845F-916133916B7D} = {9ABDFB23-5430-4410-81C3-3C0327996580}
{4792FFA1-1AD2-4230-8DE3-D2BCF1CF804F} = {9ABDFB23-5430-4410-81C3-3C0327996580}
Expand Down Expand Up @@ -160,6 +163,10 @@ Global
{9C521ED1-5221-4C93-BBA0-86C13D4C23C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C521ED1-5221-4C93-BBA0-86C13D4C23C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C521ED1-5221-4C93-BBA0-86C13D4C23C7}.Release|Any CPU.Build.0 = Release|Any CPU
{C67553AE-F09B-407D-AD3E-D61950E06BE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C67553AE-F09B-407D-AD3E-D61950E06BE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C67553AE-F09B-407D-AD3E-D61950E06BE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C67553AE-F09B-407D-AD3E-D61950E06BE8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System
{
// this type is not used anywhere, but it exists so the containing `.dll` is not empty and
// can be copied to the output folder and be dynamically loaded during test execution
public class ClassDefinedInAssemblyWithAVeryLongPath
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="ClassDefinedInAssemblyWithAVeryLongPath.cs" />
</ItemGroup>
</Project>
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.Reflection;
using Microsoft.DotNet.RemoteExecutor;
using Xunit;

Expand Down Expand Up @@ -89,5 +91,33 @@ public void ModulesAreDisposedWhenProcessIsDisposed()
process.Dispose();
Assert.Equal(expectedCount, disposedCount);
}

[ActiveIssue("https://github.com/dotnet/runtime/pull/335059")]
[ConditionalFact(typeof(PathFeatures), nameof(PathFeatures.AreAllLongPathsAvailable))]
[PlatformSpecific(TestPlatforms.Windows)]
public void LongModuleFileNamesAreSupported()
{
// To be able to test Long Path support for ProcessModule.FileName we need a .dll that has a path >= 260 chars.
// Since Long Paths support can be disabled (see the ConditionalFact attribute usage above),
// we just copy "LongName.dll" from bin to a temp directory with a long name and load it from there.
// Loading from new path is possible because the type exposed by the assembly is not referenced in any explicit way.
const string libraryName = "LongPath.dll";

string testBinPath = Path.GetDirectoryName(typeof(ProcessModuleTests).Assembly.Location);
string libraryToCopy = Path.Combine(testBinPath, libraryName);
Assert.True(File.Exists(libraryToCopy), $"{libraryName} was not present in bin folder '{testBinPath}'");

string directoryWithLongName = Path.Combine(TestDirectory, new string('a', Math.Max(1, 261 - TestDirectory.Length)));
Directory.CreateDirectory(directoryWithLongName);

string longNamePath = Path.Combine(directoryWithLongName, libraryName);
Assert.True(longNamePath.Length > 260);

File.Copy(libraryToCopy, longNamePath);

Assembly loaded = Assembly.LoadFile(longNamePath);

Assert.Contains(Process.GetCurrentProcess().Modules.Cast<ProcessModule>(), module => module.FileName == longNamePath);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
Link="Common\Microsoft\Win32\TempRegistryKey.cs" />
<Compile Include="$(CommonPath)System\Text\ValueStringBuilder.cs"
Link="Common\System\Text\ValueStringBuilder.cs" />
<Compile Include="$(CommonTestPath)System\IO\PathFeatures.cs"
Link="Common\System\IO\PathFeatures.cs" />
<Compile Include="DelegateSynchronizeInvoke.cs" />
<Compile Include="FileAssociations.cs" />
<Compile Include="Helpers.cs" />
Expand Down Expand Up @@ -50,5 +52,6 @@
<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Win32.Registry\src\Microsoft.Win32.Registry.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.DirectoryServices\src\System.DirectoryServices.csproj" />
<ProjectReference Include="LongPath\LongPath.csproj" />
</ItemGroup>
</Project>