diff --git a/src/System.Private.CoreLib/shared/System/IO/Path.Unix.cs b/src/System.Private.CoreLib/shared/System/IO/Path.Unix.cs index e5be5792085..1143c05208c 100644 --- a/src/System.Private.CoreLib/shared/System/IO/Path.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/IO/Path.Unix.cs @@ -23,6 +23,9 @@ public static string GetFullPath(string path) if (path.Length == 0) throw new ArgumentException(SR.Arg_PathEmpty, nameof(path)); + if (path.IndexOf('\0') != -1) + throw new ArgumentException(SR.Argument_InvalidPathChars, nameof(path)); + // Expand with current directory if necessary if (!IsPathRooted(path)) { diff --git a/src/System.Private.CoreLib/shared/System/IO/PathInternal.Unix.cs b/src/System.Private.CoreLib/shared/System/IO/PathInternal.Unix.cs index 1113201e708..2f65a4252bc 100644 --- a/src/System.Private.CoreLib/shared/System/IO/PathInternal.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/IO/PathInternal.Unix.cs @@ -22,13 +22,6 @@ internal static partial class PathInternal internal const string ParentDirectoryPrefix = @"../"; - /// Returns a value indicating if the given path contains invalid characters. - internal static bool HasIllegalCharacters(string path) - { - Debug.Assert(path != null); - return path.IndexOf(InvalidPathChar) >= 0; - } - internal static int GetRootLength(string path) { return path.Length > 0 && IsDirectorySeparator(path[0]) ? 1 : 0; diff --git a/src/System.Private.CoreLib/shared/System/IO/PathInternal.Windows.cs b/src/System.Private.CoreLib/shared/System/IO/PathInternal.Windows.cs index 2ab39286087..f315f43fd5b 100644 --- a/src/System.Private.CoreLib/shared/System/IO/PathInternal.Windows.cs +++ b/src/System.Private.CoreLib/shared/System/IO/PathInternal.Windows.cs @@ -146,36 +146,6 @@ internal static bool IsExtended(string path) && path[3] == '\\'; } - /// - /// Returns a value indicating if the given path contains invalid characters (", <, >, | - /// NUL, or any ASCII char whose integer representation is in the range of 1 through 31). - /// Does not check for wild card characters ? and *. - /// - internal static bool HasIllegalCharacters(string path) - { - // This is equivalent to IndexOfAny(InvalidPathChars) >= 0, - // except faster since IndexOfAny grows slower as the input - // array grows larger. - // Since we know that some of the characters we're looking - // for are contiguous in the alphabet-- the path cannot contain - // characters 0-31-- we can optimize this for our specific use - // case and use simple comparison operations. - - for (int i = 0; i < path.Length; i++) - { - char c = path[i]; - if (c <= '|') // fast path for common case - '|' is highest illegal character - { - if (c <= '\u001f' || c == '|') - { - return true; - } - } - } - - return false; - } - /// /// Check for known wildcard characters. '*' and '?' are the most common ones. /// diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs index dd01bacc491..381b4c63f7a 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs @@ -6,7 +6,8 @@ namespace System.Runtime.CompilerServices { // Calls to methods or references to fields marked with this attribute may be replaced at // some call sites with jit intrinsic expansions. - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field, Inherited = false)] + // Types marked with this attribute may be specially treated by the rumtime/compiler. + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field, Inherited = false)] internal sealed class IntrinsicAttribute : Attribute { }