Repository: dotnet/runtime
File: src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs (C#)

Code before:

        /// <summary>
        /// Encapsulates a find operation.
        /// </summary>
        /// <param name="directory">The directory to search in.</param>
        /// <param name="isNormalized">Whether the directory path is already normalized or not.</param>
        /// <param name="options">Enumeration options to use.</param>
        /// <param name="expression">The search expression to potentially use for OS-level filtering (Windows only).</param>
        internal FileSystemEnumerator(string directory, bool isNormalized, EnumerationOptions? options, string? expression) :
            this(directory, isNormalized, options)
        {
            if (_options.RecurseSubdirectories)
            {
                // We can never filter when recursing, as we need to find all subdirectories to recurse into them.
                expression = null;
            }

            if (expression is not null)
            {
                // We need to ensure that the expression is prepped to be used as an NtQueryDirectoryFile filter.
                // If the match type is simple, we need to escape the special DOS wildcard characters. If it is
                // DOS style, the characters have already been escaped in the FileSystemEnumerableFactory.

                if (expression.Length > 255
                    || expression == "*"
                    || (_options.ReturnSpecialDirectories && (expression == "." || expression == "..")))
                {
                    // Don't allow expressions longer than the maximum filename length. This comes back as
                    // STATUS_INVALID_PARAMETER from NtQueryDirectoryFile. We could catch that there, but
                    // don't want to mask other bad parameter issues.
                    //
                    // Also, an expression of "*" is pointless as a filter- it matches everything. "*.*"
                    // should have been converted to "*" already in the case of MatchType.Win32.
                    //
                    // Finally, "." and ".." are invalid filter names on their own, but we allow having them
                    // returned when Options.ReturnSpecialDirectories is set.
                    expression = null;
                }
                else if (_options.MatchType == MatchType.Simple)
                {
                    expression = FileSystemName.EscapeExpression(expression);
                }
            }

            _expression = expression;
        }

        private void Init()
        {
            // We'll only suppress the media insertion prompt on the topmost directory as that is the
            // most likely scenario and we don't want to take the perf hit for large enumerations.

Review comment (suggestion):
```suggestion
                    || (_options.ReturnSpecialDirectories && expression is "." or ".."))
```

Code after:

        /// <summary>
        /// Encapsulates a find operation.
        /// </summary>
        /// <param name="directory">The directory to search in.</param>
        /// <param name="isNormalized">Whether the directory path is already normalized or not.</param>
        /// <param name="options">Enumeration options to use.</param>
        /// <param name="expression">The search expression to potentially use for OS-level filtering (Windows only).</param>
        internal FileSystemEnumerator(string directory, bool isNormalized, EnumerationOptions? options, string? expression) :
            this(directory, isNormalized, options)
        {
            if (_options.RecurseSubdirectories)
            {
                // We can never filter when recursing, as we need to find all subdirectories to recurse into them.
                expression = null;
            }
            else if (expression is not null)
            {
                // We need to ensure that the expression is prepped to be used as an NtQueryDirectoryFile filter.
                // If the match type is simple, we need to escape the special DOS wildcard characters. If it is
                // DOS style, the characters have already been escaped in the FileSystemEnumerableFactory.

                if (expression.Length > 255 || expression is "*" or "." or "..")
                {
                    // Don't allow expressions longer than the maximum filename length. This comes back as
                    // STATUS_INVALID_PARAMETER from NtQueryDirectoryFile. We could catch that there, but
                    // don't want to mask other bad parameter issues.
                    //
                    // Also, an expression of "*" is pointless as a filter- it matches everything. "*.*"
                    // should have been converted to "*" already in the case of MatchType.Win32.
                    //
                    // Finally, "." and ".." are invalid filter names on their own, but we allow you to see
                    // these entries if you specifically ask via EnumerationOptions.ReturnSpecialDirectories.
                    expression = null;
                }
                else if (_options.MatchType == MatchType.Simple)
                {
                    expression = FileSystemName.EscapeExpression(expression);
                }
            }

            _expression = expression;
        }

        private void Init()
        {
            // We'll only suppress the media insertion prompt on the topmost directory as that is the
            // most likely scenario and we don't want to take the perf hit for large enumerations.
            // (We weren't consistent with how we handled this historically.)
            using (default(DisableMediaInsertionPrompt))
            {