From 31290fb3c50afe7561611265976a44d62934a4fc Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 30 Aug 2021 14:56:10 +0300 Subject: [PATCH 1/2] Remove the Microsoft.IO.Redist package. --- .../Microsoft.IO.Redist.sln | 42 ---- .../src/Microsoft.IO.Redist.csproj | 221 ------------------ .../src/Microsoft/IO/StringExtensions.cs | 79 ------- .../src/Microsoft/IO/ThrowHelper.cs | 16 -- .../src/Resources/Strings.resx | 125 ---------- 5 files changed, 483 deletions(-) delete mode 100644 src/libraries/Microsoft.IO.Redist/Microsoft.IO.Redist.sln delete mode 100644 src/libraries/Microsoft.IO.Redist/src/Microsoft.IO.Redist.csproj delete mode 100644 src/libraries/Microsoft.IO.Redist/src/Microsoft/IO/StringExtensions.cs delete mode 100644 src/libraries/Microsoft.IO.Redist/src/Microsoft/IO/ThrowHelper.cs delete mode 100644 src/libraries/Microsoft.IO.Redist/src/Resources/Strings.resx diff --git a/src/libraries/Microsoft.IO.Redist/Microsoft.IO.Redist.sln b/src/libraries/Microsoft.IO.Redist/Microsoft.IO.Redist.sln deleted file mode 100644 index 4ac15190a9498..0000000000000 --- a/src/libraries/Microsoft.IO.Redist/Microsoft.IO.Redist.sln +++ /dev/null @@ -1,42 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.IO.Redist", "src\Microsoft.IO.Redist.csproj", "{636F0ACF-D27A-42EB-A080-65BB5E21F4A0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{2BF3A0D1-DE74-4A55-8074-2B274EBFE805}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{23AFD1C3-1C90-4D14-9B63-A25D82CA39A7}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{408C69F5-70D5-4263-9253-5E83DD9CD764}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{06998809-AB9B-41D0-BDA9-6B70C81A763F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {636F0ACF-D27A-42EB-A080-65BB5E21F4A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {636F0ACF-D27A-42EB-A080-65BB5E21F4A0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {636F0ACF-D27A-42EB-A080-65BB5E21F4A0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {636F0ACF-D27A-42EB-A080-65BB5E21F4A0}.Release|Any CPU.Build.0 = Release|Any CPU - {23AFD1C3-1C90-4D14-9B63-A25D82CA39A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {23AFD1C3-1C90-4D14-9B63-A25D82CA39A7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {23AFD1C3-1C90-4D14-9B63-A25D82CA39A7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {23AFD1C3-1C90-4D14-9B63-A25D82CA39A7}.Release|Any CPU.Build.0 = Release|Any CPU - {2BF3A0D1-DE74-4A55-8074-2B274EBFE805}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2BF3A0D1-DE74-4A55-8074-2B274EBFE805}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2BF3A0D1-DE74-4A55-8074-2B274EBFE805}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2BF3A0D1-DE74-4A55-8074-2B274EBFE805}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {636F0ACF-D27A-42EB-A080-65BB5E21F4A0} = {408C69F5-70D5-4263-9253-5E83DD9CD764} - {23AFD1C3-1C90-4D14-9B63-A25D82CA39A7} = {408C69F5-70D5-4263-9253-5E83DD9CD764} - {2BF3A0D1-DE74-4A55-8074-2B274EBFE805} = {06998809-AB9B-41D0-BDA9-6B70C81A763F} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {4F40EC53-D415-4145-979B-B592535163C5} - EndGlobalSection -EndGlobal diff --git a/src/libraries/Microsoft.IO.Redist/src/Microsoft.IO.Redist.csproj b/src/libraries/Microsoft.IO.Redist/src/Microsoft.IO.Redist.csproj deleted file mode 100644 index 5c278ee3b83d2..0000000000000 --- a/src/libraries/Microsoft.IO.Redist/src/Microsoft.IO.Redist.csproj +++ /dev/null @@ -1,221 +0,0 @@ - - - true - Downlevel support package for System.IO classes. - $(DefineConstants);MS_IO_REDIST - true - false - annotations - true - net472 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libraries/Microsoft.IO.Redist/src/Microsoft/IO/StringExtensions.cs b/src/libraries/Microsoft.IO.Redist/src/Microsoft/IO/StringExtensions.cs deleted file mode 100644 index fbe320a857ca0..0000000000000 --- a/src/libraries/Microsoft.IO.Redist/src/Microsoft/IO/StringExtensions.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.CompilerServices; - -namespace Microsoft.IO -{ - public static class StringExtensions - { - public delegate void SpanAction(Span span, TArg arg); - - public static bool Contains(this string s, char value) - { - return s.IndexOf(value) != -1; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static bool EqualsOrdinal(this ReadOnlySpan span, ReadOnlySpan value) - { - if (span.Length != value.Length) - return false; - if (value.Length == 0) // span.Length == value.Length == 0 - return true; - return span.SequenceEqual(value); - } - - public static unsafe string Create(int length, TState state, SpanAction action) - { - if (action == null) - throw new ArgumentNullException(nameof(action)); - - if (length <= 0) - { - if (length == 0) - return string.Empty; - throw new ArgumentOutOfRangeException(nameof(length)); - } - - string result = new string('\0', length); - fixed (char* r = result) - { - action(new Span(r, length), state); - } - return result; - } - - internal static unsafe string Concat(ReadOnlySpan str0, ReadOnlySpan str1) - { - var result = new string('\0', checked(str0.Length + str1.Length)); - fixed (char* resultPtr = result) - { - var resultSpan = new Span(resultPtr, result.Length); - - str0.CopyTo(resultSpan); - str1.CopyTo(resultSpan.Slice(str0.Length)); - } - return result; - } - - internal static unsafe string Concat(ReadOnlySpan str0, ReadOnlySpan str1, ReadOnlySpan str2) - { - var result = new string('\0', checked(str0.Length + str1.Length + str2.Length)); - fixed (char* resultPtr = result) - { - var resultSpan = new Span(resultPtr, result.Length); - - str0.CopyTo(resultSpan); - resultSpan = resultSpan.Slice(str0.Length); - - str1.CopyTo(resultSpan); - resultSpan = resultSpan.Slice(str1.Length); - - str2.CopyTo(resultSpan); - } - return result; - } - } -} diff --git a/src/libraries/Microsoft.IO.Redist/src/Microsoft/IO/ThrowHelper.cs b/src/libraries/Microsoft.IO.Redist/src/Microsoft/IO/ThrowHelper.cs deleted file mode 100644 index 31e3766c51494..0000000000000 --- a/src/libraries/Microsoft.IO.Redist/src/Microsoft/IO/ThrowHelper.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; - -namespace Microsoft.IO -{ - internal static class ThrowHelper - { - internal static void ThrowEndOfFileException() - { - throw new EndOfStreamException(SR.IO_EOF_ReadBeyondEOF); - } - } -} diff --git a/src/libraries/Microsoft.IO.Redist/src/Resources/Strings.resx b/src/libraries/Microsoft.IO.Redist/src/Resources/Strings.resx deleted file mode 100644 index 66a414fe02e6d..0000000000000 --- a/src/libraries/Microsoft.IO.Redist/src/Resources/Strings.resx +++ /dev/null @@ -1,125 +0,0 @@ - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - The target file '{0}' is a directory, not a file. - - - Invalid File or Directory attributes value. - - - Second path fragment must not be a drive or UNC name. - - - Path must not be a drive. - - - File name cannot be null. - - - Path cannot be null. - - - Enum value was out of legal range. - - - Empty file name is not legal. - - - Empty path name is not legal. - - - Illegal characters in path '{0}'. - - - Invalid seek origin. - - - The directory specified, '{0}', is not a subdirectory of '{1}'. - - - Path cannot be the empty string or all whitespace. - - - Cannot create '{0}' because a file or directory with the same name already exists. - - - The specified directory '{0}' cannot be created. - - - Unable to read beyond the end of the stream. - - - The file '{0}' already exists. - - - Unable to find the specified file. - - - Could not find file '{0}'. - - - The file is too long. This operation is currently limited to supporting files less than 2 gigabytes in size. - - - The link's file system entry type is inconsistent with that of its target: {0} - - - Could not find a part of the path. - - - Could not find a part of the path '{0}'. - - - The specified file name or path is too long, or a component of the specified path is too long. - - - The process cannot access the file '{0}' because it is being used by another process. - - - The process cannot access the file because it is being used by another process. - - - Source and destination path must be different. - - - Source and destination path must have identical roots. Move will not work across volumes. - - - [Unknown] - - - Access to the path is denied. - - - Access to the path '{0}' is denied. - - - File encryption is not supported on this platform. - - - The path '{0}' is too long, or a component of the specified path is too long. - - - Basepath argument is not fully qualified. - - - The path is empty. - - - Drive name must be a root directory (i.e. 'C:\') or a drive letter ('C'). - - - Non-negative number required. - - From 0b866e16a14946177864bc66f85bf6427a46d56f Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 30 Aug 2021 15:37:50 +0300 Subject: [PATCH 2/2] Remove all conditional compilation directives with MS_IO_REDIST. --- .../IO/FileSystem.Attributes.Windows.cs | 4 -- .../FileSystem.DirectoryCreation.Windows.cs | 4 -- .../System/IO/PathInternal.CaseSensitivity.cs | 8 --- .../Common/src/System/IO/PathInternal.cs | 9 --- .../src/System/IO/Directory.cs | 7 --- .../src/System/IO/DirectoryInfo.cs | 7 --- .../System/IO/DisableMediaInsertionPrompt.cs | 6 -- .../IO/Enumeration/FileSystemEntry.Windows.cs | 4 -- .../System/IO/Enumeration/FileSystemEntry.cs | 4 -- .../IO/Enumeration/FileSystemEnumerable.cs | 4 -- .../FileSystemEnumerableFactory.cs | 4 -- .../FileSystemEnumerator.Windows.cs | 4 -- .../IO/Enumeration/FileSystemEnumerator.cs | 4 -- .../System/IO/Enumeration/FileSystemName.cs | 6 +- .../src/System/IO/EnumerationOptions.cs | 4 -- .../src/System/IO/File.cs | 61 ------------------- .../src/System/IO/FileInfo.cs | 4 -- .../src/System/IO/FileSystem.Win32.cs | 6 -- .../src/System/IO/FileSystem.Windows.cs | 4 -- .../src/System/IO/FileSystem.cs | 5 -- .../src/System/IO/FileSystemInfo.Windows.cs | 7 --- .../src/System/IO/FileSystemInfo.cs | 4 -- .../src/System/IO/MatchCasing.cs | 4 -- .../src/System/IO/MatchType.cs | 4 -- .../src/System/IO/Path.Windows.cs | 7 --- .../src/System/IO/Path.cs | 43 +------------ .../src/System/IO/SearchOption.cs | 4 -- .../src/System/IO/SearchTarget.cs | 4 -- 28 files changed, 3 insertions(+), 233 deletions(-) diff --git a/src/libraries/Common/src/System/IO/FileSystem.Attributes.Windows.cs b/src/libraries/Common/src/System/IO/FileSystem.Attributes.Windows.cs index ad087304b4e5a..7e7afcec97a72 100644 --- a/src/libraries/Common/src/System/IO/FileSystem.Attributes.Windows.cs +++ b/src/libraries/Common/src/System/IO/FileSystem.Attributes.Windows.cs @@ -9,11 +9,7 @@ using System.IO; using System.Text; -#if MS_IO_REDIST -namespace Microsoft.IO -#else namespace System.IO -#endif { internal static partial class FileSystem { diff --git a/src/libraries/Common/src/System/IO/FileSystem.DirectoryCreation.Windows.cs b/src/libraries/Common/src/System/IO/FileSystem.DirectoryCreation.Windows.cs index 821f878796e84..dba07a8fb4156 100644 --- a/src/libraries/Common/src/System/IO/FileSystem.DirectoryCreation.Windows.cs +++ b/src/libraries/Common/src/System/IO/FileSystem.DirectoryCreation.Windows.cs @@ -9,11 +9,7 @@ using System.IO; using System.Text; -#if MS_IO_REDIST -namespace Microsoft.IO -#else namespace System.IO -#endif { internal static partial class FileSystem { diff --git a/src/libraries/Common/src/System/IO/PathInternal.CaseSensitivity.cs b/src/libraries/Common/src/System/IO/PathInternal.CaseSensitivity.cs index 80fc6b43ff607..32769debc29d1 100644 --- a/src/libraries/Common/src/System/IO/PathInternal.CaseSensitivity.cs +++ b/src/libraries/Common/src/System/IO/PathInternal.CaseSensitivity.cs @@ -3,10 +3,6 @@ using System.Diagnostics; -#if MS_IO_REDIST -using Microsoft.IO; -#endif - namespace System.IO { /// Contains internal path helpers that are shared between many projects. @@ -28,11 +24,7 @@ internal static bool IsCaseSensitive { get { -#if MS_IO_REDIST - return false; // Windows is always case-insensitive -#else return !(OperatingSystem.IsWindows() || OperatingSystem.IsMacOS() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS()); -#endif } } } diff --git a/src/libraries/Common/src/System/IO/PathInternal.cs b/src/libraries/Common/src/System/IO/PathInternal.cs index ff9d79caee253..52aaa59072dd7 100644 --- a/src/libraries/Common/src/System/IO/PathInternal.cs +++ b/src/libraries/Common/src/System/IO/PathInternal.cs @@ -15,13 +15,8 @@ internal static partial class PathInternal /// internal static bool StartsWithDirectorySeparator(ReadOnlySpan path) => path.Length > 0 && IsDirectorySeparator(path[0]); -#if MS_IO_REDIST - internal static string EnsureTrailingSeparator(string path) - => EndsInDirectorySeparator(path) ? path : path + DirectorySeparatorCharAsString; -#else internal static string EnsureTrailingSeparator(string path) => EndsInDirectorySeparator(path.AsSpan()) ? path : path + DirectorySeparatorCharAsString; -#endif internal static bool IsRoot(ReadOnlySpan path) => path.Length == GetRootLength(path); @@ -248,10 +243,6 @@ internal static bool EndsInDirectorySeparator(ReadOnlySpan path) => internal static string GetLinkTargetFullPath(string path, string pathToTarget) => IsPartiallyQualified(pathToTarget.AsSpan()) ? -#if MS_IO_REDIST - Path.Combine(Path.GetDirectoryName(path), pathToTarget) : pathToTarget; -#else Path.Join(Path.GetDirectoryName(path.AsSpan()), pathToTarget.AsSpan()) : pathToTarget; -#endif } } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Directory.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Directory.cs index a30543ced5933..2bfcd01604047 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Directory.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Directory.cs @@ -5,16 +5,9 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; - -#if MS_IO_REDIST -using Microsoft.IO.Enumeration; - -namespace Microsoft.IO -#else using System.IO.Enumeration; namespace System.IO -#endif { public static partial class Directory { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs b/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs index da8cdec7ab0ee..1aeef2f7501a8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs @@ -5,16 +5,9 @@ using System.IO; using System.Collections.Generic; using System.Diagnostics; - -#if MS_IO_REDIST -using Microsoft.IO.Enumeration; - -namespace Microsoft.IO -#else using System.IO.Enumeration; namespace System.IO -#endif { public sealed partial class DirectoryInfo : FileSystemInfo { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/DisableMediaInsertionPrompt.cs b/src/libraries/System.Private.CoreLib/src/System/IO/DisableMediaInsertionPrompt.cs index 6510200f2c2fb..6ea4d7893f272 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/DisableMediaInsertionPrompt.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/DisableMediaInsertionPrompt.cs @@ -1,13 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if MS_IO_REDIST -using System; - -namespace Microsoft.IO -#else namespace System.IO -#endif { /// /// Simple wrapper to safely disable the normal media insertion prompt for diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEntry.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEntry.Windows.cs index 76c0e277f05bd..27a15cb6c192b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEntry.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEntry.Windows.cs @@ -4,11 +4,7 @@ using System; using System.IO; -#if MS_IO_REDIST -namespace Microsoft.IO.Enumeration -#else namespace System.IO.Enumeration -#endif { /// Provides a lower level view of to help process and filter find results. public unsafe ref partial struct FileSystemEntry diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEntry.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEntry.cs index 7ec26cc0f0a44..bea0714fdf211 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEntry.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEntry.cs @@ -4,11 +4,7 @@ using System; using System.IO; -#if MS_IO_REDIST -namespace Microsoft.IO.Enumeration -#else namespace System.IO.Enumeration -#endif { /// Provides a lower level view of to help process and filter find results. public ref partial struct FileSystemEntry diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerable.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerable.cs index 0785e2e10ce4f..3f2e5a3b324ad 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerable.cs @@ -6,11 +6,7 @@ using System.Collections.Generic; using System.Threading; -#if MS_IO_REDIST -namespace Microsoft.IO.Enumeration -#else namespace System.IO.Enumeration -#endif { /// /// Enumerable that allows utilizing custom filter predicates and tranform delegates. diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerableFactory.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerableFactory.cs index 378d037bb0fd2..00868756b91d1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerableFactory.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerableFactory.cs @@ -5,11 +5,7 @@ using System.Collections.Generic; using System.IO; -#if MS_IO_REDIST -namespace Microsoft.IO.Enumeration -#else namespace System.IO.Enumeration -#endif { internal static class FileSystemEnumerableFactory { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs index 46b5cbc9bc131..265ac541bed12 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs @@ -11,11 +11,7 @@ using System.Runtime.InteropServices; using System.Threading; -#if MS_IO_REDIST -namespace Microsoft.IO.Enumeration -#else namespace System.IO.Enumeration -#endif { /// Enumerates the file system elements of the provided type that are being searched and filtered by a . public unsafe abstract partial class FileSystemEnumerator : CriticalFinalizerObject, IEnumerator diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.cs index 07dbad8408470..6f22a9729b5d0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.cs @@ -6,11 +6,7 @@ using System.Collections.Generic; using System.Runtime.ConstrainedExecution; -#if MS_IO_REDIST -namespace Microsoft.IO.Enumeration -#else namespace System.IO.Enumeration -#endif { /// Enumerates the file system elements of the provided type that are being searched and filtered by a . /// The type of the result produced by this file system enumerator. diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemName.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemName.cs index fc3c83e4837b2..6ee823c5739db 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemName.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemName.cs @@ -4,11 +4,7 @@ using System; using System.Text; -#if MS_IO_REDIST -namespace Microsoft.IO.Enumeration -#else namespace System.IO.Enumeration -#endif { /// Provides methods for matching file system names. public static class FileSystemName @@ -101,7 +97,7 @@ public static bool MatchesSimpleExpression(ReadOnlySpan expression, ReadOn // cannot contain wildcards, while the expression may contain wildcards. // // Expression wild cards are evaluated as shown in the nondeterministic - // finite automatons below. Note that ~* and ~? are DOS_STAR and DOS_QM. + // finite automata below. Note that ~* and ~? are DOS_STAR and DOS_QM. // // ~* is DOS_STAR, ~? is DOS_QM, and ~. is DOS_DOT // diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/EnumerationOptions.cs b/src/libraries/System.Private.CoreLib/src/System/IO/EnumerationOptions.cs index 952d8132488c2..a48d7ce4d0b17 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/EnumerationOptions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/EnumerationOptions.cs @@ -4,11 +4,7 @@ using System; using System.IO; -#if MS_IO_REDIST -namespace Microsoft.IO -#else namespace System.IO -#endif { /// Provides file and directory enumeration options. public class EnumerationOptions diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/File.cs b/src/libraries/System.Private.CoreLib/src/System/IO/File.cs index ff2a7bd9ef628..ce698cd9c9b55 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/File.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/File.cs @@ -12,14 +12,7 @@ using System.Threading.Tasks; using Microsoft.Win32.SafeHandles; -#if MS_IO_REDIST -using System; -using System.IO; - -namespace Microsoft.IO -#else namespace System.IO -#endif { // Class for creating FileStream objects, and some basic file management // routines such as Delete, etc. @@ -340,11 +333,9 @@ public static byte[] ReadAllBytes(string path) } else if (fileLength == 0) { -#if !MS_IO_REDIST // Some file systems (e.g. procfs on Linux) return 0 for length even when there's content. // Thus we need to assume 0 doesn't mean empty. return ReadAllBytesUnknownLength(fs); -#endif } int index = 0; @@ -374,13 +365,8 @@ public static void WriteAllBytes(string path, byte[] bytes) if (bytes == null) throw new ArgumentNullException(nameof(bytes)); -#if MS_IO_REDIST - using FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read); - fs.Write(bytes, 0, bytes.Length); -#else using SafeFileHandle sfh = OpenHandle(path, FileMode.Create, FileAccess.Write, FileShare.Read); RandomAccess.WriteAtOffset(sfh, bytes, 0); -#endif } public static string[] ReadAllLines(string path) { @@ -666,11 +652,7 @@ private static async Task InternalReadAllTextAsync(string path, Encoding StringBuilder sb = new StringBuilder(); while (true) { -#if MS_IO_REDIST - int read = await sr.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false); -#else int read = await sr.ReadAsync(new Memory(buffer), cancellationToken).ConfigureAwait(false); -#endif if (read == 0) { return sb.ToString(); @@ -733,9 +715,7 @@ private static async Task InternalReadAllTextAsync(string path, Encoding if (fileLength > int.MaxValue) { var e = new IOException(SR.IO_FileTooLong2GB); -#if !MS_IO_REDIST ExceptionDispatchInfo.SetCurrentStackTrace(e); -#endif return Task.FromException(e); } @@ -761,11 +741,7 @@ private static async Task InternalReadAllBytesAsync(FileStream fs, int c byte[] bytes = new byte[count]; do { -#if MS_IO_REDIST - int n = await fs.ReadAsync(bytes, index, count - index, cancellationToken).ConfigureAwait(false); -#else int n = await fs.ReadAsync(new Memory(bytes, index, count - index), cancellationToken).ConfigureAwait(false); -#endif if (n == 0) { ThrowHelper.ThrowEndOfFileException(); @@ -804,11 +780,7 @@ private static async Task InternalReadAllBytesUnknownLengthAsync(FileStr } Debug.Assert(bytesRead < rentedArray.Length); -#if MS_IO_REDIST - int n = await fs.ReadAsync(rentedArray, bytesRead, rentedArray.Length - bytesRead, cancellationToken).ConfigureAwait(false); -#else int n = await fs.ReadAsync(rentedArray.AsMemory(bytesRead), cancellationToken).ConfigureAwait(false); -#endif if (n == 0) { return rentedArray.AsSpan(0, bytesRead).ToArray(); @@ -838,13 +810,8 @@ private static async Task InternalReadAllBytesUnknownLengthAsync(FileStr static async Task Core(string path, byte[] bytes, CancellationToken cancellationToken) { -#if MS_IO_REDIST - using FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, 1, FileOptions.Asynchronous | FileOptions.SequentialScan); - await fs.WriteAsync(bytes, 0, bytes.Length, cancellationToken).ConfigureAwait(false); -#else using SafeFileHandle sfh = OpenHandle(path, FileMode.Create, FileAccess.Write, FileShare.Read, FileOptions.Asynchronous | FileOptions.SequentialScan); await RandomAccess.WriteAtOffsetAsync(sfh, bytes, 0, cancellationToken).ConfigureAwait(false); -#endif } } @@ -924,39 +891,11 @@ private static async Task InternalWriteAllLinesAsync(TextWriter writer, IEnumera private static async Task InternalWriteAllTextAsync(StreamWriter sw, string contents, CancellationToken cancellationToken) { -#if MS_IO_REDIST - char[]? buffer = null; - try - { - buffer = ArrayPool.Shared.Rent(DefaultBufferSize); - int count = contents.Length; - int index = 0; - while (index < count) - { - int batchSize = Math.Min(DefaultBufferSize, count - index); - contents.CopyTo(index, buffer, 0, batchSize); - await sw.WriteAsync(buffer, 0, batchSize).ConfigureAwait(false); - index += batchSize; - } - - cancellationToken.ThrowIfCancellationRequested(); - await sw.FlushAsync().ConfigureAwait(false); - } - finally - { - sw.Dispose(); - if (buffer != null) - { - ArrayPool.Shared.Return(buffer); - } - } -#else using (sw) { await sw.WriteAsync(contents.AsMemory(), cancellationToken).ConfigureAwait(false); await sw.FlushAsync().ConfigureAwait(false); } -#endif } public static Task AppendAllTextAsync(string path, string? contents, CancellationToken cancellationToken = default(CancellationToken)) diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileInfo.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileInfo.cs index c7401018a8381..4f42c95ff454f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileInfo.cs @@ -7,11 +7,7 @@ using System.Text; using System.Runtime.Versioning; -#if MS_IO_REDIST -namespace Microsoft.IO -#else namespace System.IO -#endif { // Class for creating FileStream objects, and some basic file management // routines such as Delete, etc. diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Win32.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Win32.cs index 250b98bcc75a8..a9893cd1736c5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Win32.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Win32.cs @@ -4,13 +4,7 @@ using System; using System.Runtime.InteropServices; -#if MS_IO_REDIST -using System.IO; - -namespace Microsoft.IO -#else namespace System.IO -#endif { internal static partial class FileSystem { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs index d2bde47c3134b..289c686760092 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs @@ -10,11 +10,7 @@ using System.Text; using System.Buffers; -#if MS_IO_REDIST -namespace Microsoft.IO -#else namespace System.IO -#endif { internal static partial class FileSystem { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.cs index a1d506e9218c8..09f6000326111 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.cs @@ -1,12 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if MS_IO_REDIST -using System; -namespace Microsoft.IO -#else namespace System.IO -#endif { internal static partial class FileSystem { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.Windows.cs index bb1440851733c..cadd69ce7e67a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.Windows.cs @@ -4,16 +4,9 @@ using System; using System.Diagnostics; using System.IO; - -#if MS_IO_REDIST -using Microsoft.IO.Enumeration; - -namespace Microsoft.IO -#else using System.IO.Enumeration; namespace System.IO -#endif { public partial class FileSystemInfo { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.cs index 3beed9e25635e..eb4111efee2b2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystemInfo.cs @@ -5,11 +5,7 @@ using System.IO; using System.Runtime.Serialization; -#if MS_IO_REDIST -namespace Microsoft.IO -#else namespace System.IO -#endif { public abstract partial class FileSystemInfo : MarshalByRefObject, ISerializable { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/MatchCasing.cs b/src/libraries/System.Private.CoreLib/src/System/IO/MatchCasing.cs index 607ebe54c2813..0567042cdd7a1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/MatchCasing.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/MatchCasing.cs @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if MS_IO_REDIST -namespace Microsoft.IO -#else namespace System.IO -#endif { /// Specifies the type of character casing to match. public enum MatchCasing diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/MatchType.cs b/src/libraries/System.Private.CoreLib/src/System/IO/MatchType.cs index 857796c938255..d157b13ad5ac4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/MatchType.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/MatchType.cs @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if MS_IO_REDIST -namespace Microsoft.IO -#else namespace System.IO -#endif { /// Specifies the type of wildcard matching to use. public enum MatchType diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs index e0ad5c0c26af2..b10cedd4ecbdd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs @@ -5,14 +5,7 @@ using System.Diagnostics.CodeAnalysis; using System.Text; -#if MS_IO_REDIST -using System; -using System.IO; - -namespace Microsoft.IO -#else namespace System.IO -#endif { public static partial class Path { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Path.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Path.cs index 49623b583e640..3732397f17ba0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Path.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Path.cs @@ -6,14 +6,7 @@ using System.Runtime.InteropServices; using System.Text; -#if MS_IO_REDIST -using System; -using System.IO; - -namespace Microsoft.IO -#else namespace System.IO -#endif { // Provides methods for processing file system strings in a cross-platform manner. // Most of the methods don't do a complete parsing (such as examining a UNC hostname), @@ -77,15 +70,9 @@ public static partial class Path } ReadOnlySpan subpath = path.AsSpan(0, subLength); -#if MS_IO_REDIST - return extension.Length != 0 && extension[0] == '.' ? - StringExtensions.Concat(subpath, extension.AsSpan()) : - StringExtensions.Concat(subpath, ".".AsSpan(), extension.AsSpan()); -#else return extension.StartsWith('.') ? string.Concat(subpath, extension) : string.Concat(subpath, ".", extension); -#endif } /// @@ -253,11 +240,7 @@ public static unsafe string GetRandomFileName() byte* pKey = stackalloc byte[KeyLength]; Interop.GetRandomBytes(pKey, KeyLength); -#if MS_IO_REDIST - return StringExtensions.Create( -#else return string.Create( -#endif 12, (IntPtr)pKey, (span, key) => // 12 == 8 + 1 (for period) + 3 Populate83FileNameFromRandomBytes((byte*)key, KeyLength, span)); } @@ -645,25 +628,9 @@ private static unsafe string JoinInternal(ReadOnlySpan first, ReadOnlySpan bool hasSeparator = PathInternal.IsDirectorySeparator(first[first.Length - 1]) || PathInternal.IsDirectorySeparator(second[0]); -#if !MS_IO_REDIST return hasSeparator ? string.Concat(first, second) : string.Concat(first, PathInternal.DirectorySeparatorCharAsString, second); -#else - fixed (char* f = &MemoryMarshal.GetReference(first), s = &MemoryMarshal.GetReference(second)) - { - return StringExtensions.Create( - first.Length + second.Length + (hasSeparator ? 0 : 1), - (First: (IntPtr)f, FirstLength: first.Length, Second: (IntPtr)s, SecondLength: second.Length), - static (destination, state) => - { - new Span((char*)state.First, state.FirstLength).CopyTo(destination); - if (destination.Length != (state.FirstLength + state.SecondLength)) - destination[state.FirstLength] = PathInternal.DirectorySeparatorChar; - new Span((char*)state.Second, state.SecondLength).CopyTo(destination.Slice(destination.Length - state.SecondLength)); - }); - } -#endif } private unsafe readonly struct Join3Payload @@ -702,11 +669,8 @@ private static unsafe string JoinInternal(ReadOnlySpan first, ReadOnlySpan var payload = new Join3Payload( f, first.Length, s, second.Length, t, third.Length, (byte)(firstNeedsSeparator | secondNeedsSeparator << 1)); -#if MS_IO_REDIST - return StringExtensions.Create( -#else + return string.Create( -#endif first.Length + second.Length + third.Length + firstNeedsSeparator + secondNeedsSeparator, (IntPtr)(&payload), static (destination, statePtr) => @@ -765,11 +729,8 @@ private static unsafe string JoinInternal(ReadOnlySpan first, ReadOnlySpan var payload = new Join4Payload( f, first.Length, s, second.Length, t, third.Length, u, fourth.Length, (byte)(firstNeedsSeparator | secondNeedsSeparator << 1 | thirdNeedsSeparator << 2)); -#if MS_IO_REDIST - return StringExtensions.Create( -#else + return string.Create( -#endif first.Length + second.Length + third.Length + fourth.Length + firstNeedsSeparator + secondNeedsSeparator + thirdNeedsSeparator, (IntPtr)(&payload), static (destination, statePtr) => diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/SearchOption.cs b/src/libraries/System.Private.CoreLib/src/System/IO/SearchOption.cs index c7fd2be70b68a..b37681889ada3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/SearchOption.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/SearchOption.cs @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if MS_IO_REDIST -namespace Microsoft.IO -#else namespace System.IO -#endif { /// /// Enum describing whether the search operation should diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/SearchTarget.cs b/src/libraries/System.Private.CoreLib/src/System/IO/SearchTarget.cs index a1bed2ae7ff16..2b1bc9d89feac 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/SearchTarget.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/SearchTarget.cs @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if MS_IO_REDIST -namespace Microsoft.IO -#else namespace System.IO -#endif { internal enum SearchTarget {