Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit f1d6d81

Browse files
committed
Merge pull request #2045 from stephentoub/pathinternal_refactor
Refactor PathInternal.*.cs partial files
2 parents 57b6704 + f16697a commit f1d6d81

File tree

8 files changed

+80
-84
lines changed

8 files changed

+80
-84
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Diagnostics.Contracts;
5+
6+
namespace System.IO
7+
{
8+
/// <summary>Contains internal path helpers that are shared between many projects.</summary>
9+
internal static partial class PathInternal
10+
{
11+
/// <summary>Returns a comparison that can be used to compare file and directory names for equality.</summary>
12+
internal static StringComparison GetComparison()
13+
{
14+
return StringComparison.OrdinalIgnoreCase;
15+
}
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Diagnostics.Contracts;
5+
6+
namespace System.IO
7+
{
8+
/// <summary>Contains internal path helpers that are shared between many projects.</summary>
9+
internal static partial class PathInternal
10+
{
11+
/// <summary>Returns a comparison that can be used to compare file and directory names for equality.</summary>
12+
internal static StringComparison GetComparison()
13+
{
14+
return StringComparison.Ordinal;
15+
}
16+
}
17+
}

src/Common/src/System/IO/PathInternal.OSX.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/Common/src/System/IO/PathInternal.Linux.cs renamed to src/Common/src/System/IO/PathInternal.Unix.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55

66
namespace System.IO
77
{
8-
/// <summary>
9-
/// Contains internal path helpers that are shared between many projects.
10-
/// </summary>
11-
internal static class PathInternal
8+
/// <summary>Contains internal path helpers that are shared between many projects.</summary>
9+
internal static partial class PathInternal
1210
{
13-
/// <summary>
14-
/// Returns a value indicating if the given path contains invalid characters.
15-
/// </summary>
11+
/// <summary>Returns a value indicating if the given path contains invalid characters.</summary>
1612
internal static bool HasIllegalCharacters(string path, bool checkAdditional = false)
1713
{
1814
Contract.Requires(path != null);
@@ -25,19 +21,11 @@ internal static bool HasIllegalCharacters(string path, bool checkAdditional = fa
2521

2622
// checkAdditional is meant to check for additional characters
2723
// permitted in a search path but disallowed in a normal path.
28-
// In Windows this is * and ?,but Linux and OSX permit such characters
24+
// In Windows this is * and ?,but Unix permits such characters
2925
// in the filename so checkAdditional is ignored.
3026
}
3127

3228
return false;
3329
}
34-
35-
/// <summary>
36-
/// Returns a comparison that can be used to compare file and directory names for equality.
37-
/// </summary>
38-
internal static StringComparison GetComparison()
39-
{
40-
return StringComparison.Ordinal;
41-
}
4230
}
4331
}

src/Common/src/System/IO/PathInternal.Windows.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55

66
namespace System.IO
77
{
8-
/// <summary>
9-
/// Contains internal path helpers that are shared between many projects.
10-
/// </summary>
11-
internal static class PathInternal
8+
/// <summary>Contains internal path helpers that are shared between many projects.</summary>
9+
internal static partial class PathInternal
1210
{
1311
/// <summary>
14-
/// Returns a value indicating if the given path contains invalid characters (", &lt;, &gt;, |
15-
/// NUL, or any ASCII char whose integer representation is in the range of 1 through 31),
16-
/// optionally checking for ? and *.
12+
/// Returns a value indicating if the given path contains invalid characters (", &lt;, &gt;, |
13+
/// NUL, or any ASCII char whose integer representation is in the range of 1 through 31),
14+
/// optionally checking for ? and *.
1715
/// </summary>
1816
internal static bool HasIllegalCharacters(string path, bool checkAdditional = false)
1917
{
@@ -35,13 +33,5 @@ internal static bool HasIllegalCharacters(string path, bool checkAdditional = fa
3533

3634
return false;
3735
}
38-
39-
/// <summary>
40-
/// Returns a comparison that can be used to compare file and directory names for equality.
41-
/// </summary>
42-
internal static StringComparison GetComparison()
43-
{
44-
return StringComparison.OrdinalIgnoreCase;
45-
}
4636
}
4737
}

src/System.IO.Compression.ZipFile/src/System.IO.Compression.ZipFile.csproj

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,30 @@
2525
<Compile Include="$(CommonPath)\System\IO\PathInternal.Windows.cs">
2626
<Link>Common\System\IO\PathInternal.Windows.cs</Link>
2727
</Compile>
28+
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseInsensitive.cs">
29+
<Link>Common\System\IO\PathInternal.CaseInsensitive.cs</Link>
30+
</Compile>
31+
</ItemGroup>
32+
<!-- Unix -->
33+
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
34+
<Compile Include="$(CommonPath)\System\IO\PathInternal.Unix.cs">
35+
<Link>Common\System\IO\PathInternal.Unix.cs</Link>
36+
</Compile>
2837
</ItemGroup>
2938
<!-- Linux -->
3039
<ItemGroup Condition="'$(TargetsLinux)' == 'true'">
31-
<Compile Include="$(CommonPath)\System\IO\PathInternal.Linux.cs">
32-
<Link>Common\System\IO\PathInternal.Linux.cs</Link>
40+
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseSensitive.cs">
41+
<Link>Common\System\IO\PathInternal.CaseSensitive.cs</Link>
3342
</Compile>
3443
</ItemGroup>
3544
<!-- OSX -->
3645
<ItemGroup Condition="'$(TargetsOSX)' == 'true'">
37-
<Compile Include="$(CommonPath)\System\IO\PathInternal.OSX.cs">
38-
<Link>Common\System\IO\PathInternal.OSX.cs</Link>
46+
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseInsensitive.cs">
47+
<Link>Common\System\IO\PathInternal.CaseInsensitive.cs</Link>
3948
</Compile>
4049
</ItemGroup>
4150
<ItemGroup>
4251
<None Include="project.json" />
4352
</ItemGroup>
4453
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
45-
</Project>
54+
</Project>

src/System.IO.FileSystem.DriveInfo/src/System.IO.FileSystem.DriveInfo.csproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
<Compile Include="$(CommonPath)\System\IO\PathInternal.Windows.cs">
7070
<Link>Common\System\IO\PathInternal.Windows.cs</Link>
7171
</Compile>
72+
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseInsensitive.cs">
73+
<Link>Common\System\IO\PathInternal.CaseInsensitive.cs</Link>
74+
</Compile>
7275
</ItemGroup>
7376
<ItemGroup Condition=" '$(TargetsUnix)' == 'true' ">
7477
<Compile Include="$(CommonPath)\Interop\Unix\Interop.Libraries.cs">
@@ -86,6 +89,9 @@
8689
<Compile Include="$(CommonPath)\Interop\Unix\libc\Interop.strerror.cs">
8790
<Link>Common\Interop\Unix\Interop.strerror.cs</Link>
8891
</Compile>
92+
<Compile Include="$(CommonPath)\System\IO\PathInternal.Unix.cs">
93+
<Link>Common\System\IO\PathInternal.Unix.cs</Link>
94+
</Compile>
8995
</ItemGroup>
9096
<ItemGroup Condition=" '$(TargetsLinux)' == 'true' ">
9197
<Compile Include="System\IO\DriveInfo.Linux.cs" />
@@ -104,6 +110,9 @@
104110
<Compile Include="$(CommonPath)\Interop\Linux\Interop.Errors.cs">
105111
<Link>Common\Interop\Linux\Interop.Errors.cs</Link>
106112
</Compile>
113+
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseSensitive.cs">
114+
<Link>Common\System\IO\PathInternal.CaseSensitive.cs</Link>
115+
</Compile>
107116
</ItemGroup>
108117
<ItemGroup Condition=" '$(TargetsOSX)' == 'true' ">
109118
<Compile Include="System\IO\DriveInfo.OSX.cs" />
@@ -114,9 +123,12 @@
114123
<Compile Include="$(CommonPath)\Interop\OSX\Interop.Errors.cs">
115124
<Link>Common\Interop\OSX\Interop.Errors.cs</Link>
116125
</Compile>
126+
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseInsensitive.cs">
127+
<Link>Common\System\IO\PathInternal.CaseInsensitive.cs</Link>
128+
</Compile>
117129
</ItemGroup>
118130
<ItemGroup>
119131
<None Include="project.json" />
120132
</ItemGroup>
121133
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
122-
</Project>
134+
</Project>

src/System.IO.FileSystem/src/System.IO.FileSystem.csproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
<Compile Include="$(CommonPath)\System\IO\PathInternal.Windows.cs">
7575
<Link>Common\System\IO\PathInternal.Windows.cs</Link>
7676
</Compile>
77+
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseInsensitive.cs">
78+
<Link>Common\System\IO\PathInternal.CaseInsensitive.cs</Link>
79+
</Compile>
7780
<Compile Include="$(CommonPath)\System\IO\Win32Marshal.cs">
7881
<Link>Common\System\IO\Win32Marshal.cs</Link>
7982
</Compile>
@@ -302,12 +305,15 @@
302305
<Compile Include="$(CommonPath)\Interop\Unix\libcoreclr\Interop.GetFileInformation.cs">
303306
<Link>Common\Interop\Unix\Interop.GetInformation.cs</Link>
304307
</Compile>
308+
<Compile Include="$(CommonPath)\System\IO\PathInternal.Unix.cs">
309+
<Link>Common\System\IO\PathInternal.Unix.cs</Link>
310+
</Compile>
305311
</ItemGroup>
306312
<!-- Linux -->
307313
<ItemGroup Condition="'$(TargetsLinux)' == 'true'">
308314
<Compile Include="System\IO\UnixFileStream.Linux.cs" />
309-
<Compile Include="$(CommonPath)\System\IO\PathInternal.Linux.cs">
310-
<Link>Common\System\IO\PathInternal.Linux.cs</Link>
315+
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseSensitive.cs">
316+
<Link>Common\System\IO\PathInternal.CaseSensitive.cs</Link>
311317
</Compile>
312318
<Compile Include="$(CommonPath)\Interop\Linux\Interop.Errors.cs">
313319
<Link>Common\Interop\Linux\Interop.Errors.cs</Link>
@@ -327,8 +333,8 @@
327333
</ItemGroup>
328334
<!-- OSX -->
329335
<ItemGroup Condition="'$(TargetsOSX)' == 'true'">
330-
<Compile Include="$(CommonPath)\System\IO\PathInternal.OSX.cs">
331-
<Link>Common\System\IO\PathInternal.OSX.cs</Link>
336+
<Compile Include="$(CommonPath)\System\IO\PathInternal.CaseInsensitive.cs">
337+
<Link>Common\System\IO\PathInternal.CaseInsensitive.cs</Link>
332338
</Compile>
333339
<Compile Include="$(CommonPath)\Interop\OSX\libc\Interop.readdir.cs">
334340
<Link>Common\Interop\OSX\Interop.readdir.cs</Link>

0 commit comments

Comments
 (0)