Repository: PowerShell/PowerShell
File: src/System.Management.Automation/utils/PathUtils.cs (C#)

Code before:
                // not qualified if you don't have a valid drive. "=:\" is the "=" file's default data stream.
                && IsValidDriveChar(path[0]));
        }
        /// <summary>
        /// True if the given character is a directory separator.
        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static bool IsDirectorySeparator(char c)
        {
            return c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar;
        }

        #endregion

        #region Helpers for checking invalid paths using SearchValues

        /// <summary>
        /// Contains characters that are invalid in file names.
        /// </summary>
        private static readonly SearchValues<char> InvalidFileNameChars
            = SearchValues.Create(Path.GetInvalidFileNameChars());

        /// <summary>
        /// Contains characters that are invalid in path names.
        /// </summary>
        private static readonly SearchValues<char> InvalidPathChars
            = SearchValues.Create(Path.GetInvalidPathChars());

        /// <summary>
        /// Checks if the specified path contains any characters that are invalid in file names.
        /// </summary>
        /// <param name="path">The path to check.</param>
        /// <returns>True if the path contains invalid file name characters, otherwise false.</returns>
        internal static bool ContainsInvalidFileNameChars(ReadOnlySpan<char> path)
            => path.ContainsAny(InvalidFileNameChars);

        /// <summary>
        /// Checks if the specified path contains any characters that are invalid in path names.
        /// </summary>
        /// <param name="path">The path to check.</param>
        /// <returns>True if the path contains invalid path characters, otherwise false.</returns>
        internal static bool ContainsInvalidPathChars(ReadOnlySpan<char> path)
            => path.ContainsAny(InvalidPathChars);

        #endregion
    }
}


Review comment (suggestion):
```
        private static readonly SearchValues<char> s_invalidPathChars
```

Code after:
                // not qualified if you don't have a valid drive. "=:\" is the "=" file's default data stream.
                && IsValidDriveChar(path[0]));
        }
        /// <summary>
        /// True if the given character is a directory separator.
        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static bool IsDirectorySeparator(char c)
        {
            return c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar;
        }

        #endregion

        #region Helpers for checking invalid paths using SearchValues

        /// <summary>
        /// Contains characters that are invalid in file names.
        /// </summary>
        private static readonly SearchValues<char> s_invalidFileNameChars
            = SearchValues.Create(Path.GetInvalidFileNameChars());

        /// <summary>
        /// Contains characters that are invalid in path names.
        /// </summary>
        private static readonly SearchValues<char> s_invalidPathChars
            = SearchValues.Create(Path.GetInvalidPathChars());

        /// <summary>
        /// Checks if the specified filename contains any characters that are invalid in file names.
        /// </summary>
        /// <param name="filename">The path to check.</param>
        /// <returns>True if the filename contains invalid file name characters, otherwise false.</returns>
        internal static bool ContainsInvalidFileNameChars(ReadOnlySpan<char> filename)
            => filename.ContainsAny(s_invalidFileNameChars);

        /// <summary>
        /// Checks if the specified path contains any characters that are invalid in path names.
        /// </summary>
        /// <param name="path">The path to check.</param>
        /// <returns>True if the path contains invalid path characters, otherwise false.</returns>
        internal static bool ContainsInvalidPathChars(ReadOnlySpan<char> path)
            => path.ContainsAny(s_invalidPathChars);

        #endregion
    }
}