Repository: PowerShell/PowerShell
File: src/Microsoft.PowerShell.Commands.Management/commands/management/NewPropertyCommand.cs (C#)

Code before:
        /// Returns completion results for PropertyType parameter.
        /// </summary>
        /// <param name="commandName">The command name.</param>
        /// <param name="parameterName">The parameter name.</param>
        /// <param name="wordToComplete">The word to complete.</param>
        /// <param name="commandAst">The command AST.</param>
        /// <param name="fakeBoundParameters">The fake bound parameters.</param>
        /// <returns>List of Completion Results.</returns>
        public IEnumerable<CompletionResult> CompleteArgument(
            string commandName,
            string parameterName,
            string wordToComplete,
            CommandAst commandAst,
            IDictionary fakeBoundParameters)
        {
            if (!IsRegistryProvider(fakeBoundParameters))
            {
                yield break;
            }

            foreach (CompletionResult result in CompletionCompleters.EnumerateQuotedAndUnquotedCompletionText(
                wordToComplete,
                possibleCompletionValues: s_RegistryPropertyTypes,
                toolTipMapping: GetRegistryPropertyTypeToolTip))
            {
                yield return result;
            }
        }

        /// <summary>
        /// Checks if parameter paths are from Registry provider.
        /// </summary>
        /// <param name="fakeBoundParameters">The fake bound parameters.</param>
        /// <returns>Boolean indicating if paths are from Registry Provider.</returns>
        private static bool IsRegistryProvider(IDictionary fakeBoundParameters)
        {
            Collection<PathInfo> paths;

            if (fakeBoundParameters.Contains("Path"))
            {
                paths = ResolvePath(fakeBoundParameters["Path"], isLiteralPath: false);
            }
            else if (fakeBoundParameters.Contains("LiteralPath"))
            {
                paths = ResolvePath(fakeBoundParameters["LiteralPath"], isLiteralPath: true);
            }
            else
            {
                paths = ResolvePath(@".\", isLiteralPath: false);
            }


Review comment (suggestion):
It seems we can remove rest yield-s too. I'm not against using yield-s, but still, the code is better readable and better generated without them.
```c#
            => IsRegistryProvider(fakeBoundParameters) ?
                    CompletionCompleters.EnumerateQuotedAndUnquotedCompletionText(
                        wordToComplete,
                        possibleCompletionValues: s_RegistryPropertyTypes,
                        toolTipMapping: GetRegistryPropertyTypeToolTip))
                  : Array.Empty<CompletionResult>;
            }

```

Code after:
        /// Returns completion results for PropertyType parameter.
        /// </summary>
        /// <param name="commandName">The command name.</param>
        /// <param name="parameterName">The parameter name.</param>
        /// <param name="wordToComplete">The word to complete.</param>
        /// <param name="commandAst">The command AST.</param>
        /// <param name="fakeBoundParameters">The fake bound parameters.</param>
        /// <returns>List of Completion Results.</returns>
        public IEnumerable<CompletionResult> CompleteArgument(
            string commandName,
            string parameterName,
            string wordToComplete,
            CommandAst commandAst,
            IDictionary fakeBoundParameters)
                => IsRegistryProvider(fakeBoundParameters)
                    ? CompletionCompleters.GetMatchingResults(
                        wordToComplete,
                        possibleCompletionValues: s_RegistryPropertyTypes,
                        toolTipMapping: GetRegistryPropertyTypeToolTip,
                        resultType: CompletionResultType.ParameterValue)
                    : [];

        /// <summary>
        /// Checks if parameter paths are from Registry provider.
        /// </summary>
        /// <param name="fakeBoundParameters">The fake bound parameters.</param>
        /// <returns>Boolean indicating if paths are from Registry Provider.</returns>
        private static bool IsRegistryProvider(IDictionary fakeBoundParameters)
        {
            Collection<PathInfo> paths;

            if (fakeBoundParameters.Contains("Path"))
            {
                paths = ResolvePath(fakeBoundParameters["Path"], isLiteralPath: false);
            }
            else if (fakeBoundParameters.Contains("LiteralPath"))
            {
                paths = ResolvePath(fakeBoundParameters["LiteralPath"], isLiteralPath: true);
            }
            else
            {
                paths = ResolvePath(@".\", isLiteralPath: false);
            }

            return paths.Count > 0 && paths[0].Provider.NameEquals("Registry");
        }

        /// <summary>
        /// Resolve path or literal path using Resolve-Path.
        /// </summary>
        /// <param name="path">The path to resolve.</param>