Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs (C#)

Code before:

                            continue;
                        }

                        var switchPair = boundArgument.Value as SwitchPair;
                        if (switchPair != null)
                        {
                            result[boundArgument.Key] = switchPair.Argument;
                            continue;
                        }
                        // Ignored:
                        //     AstArrayPair - only used for ValueFromRemainingArguments, not that useful for tab completion
                        //     FakePair - missing argument, not that useful
                        //     PipeObjectPair - no actual argument, makes for a poor api
                    }
                }
            }

            return result;
        }

        private static ScriptBlock GetCustomArgumentCompleter(
            string optionKey,
            IEnumerable<string> keys,
            CompletionContext context)
        {
            ScriptBlock scriptBlock;
            var options = context.Options;
            if (options != null)
            {
                var customCompleters = options[optionKey] as Hashtable;
                if (customCompleters != null)
                {
                    foreach (var key in keys)
                    {
                        if (customCompleters.ContainsKey(key))
                        {
                            scriptBlock = customCompleters[key] as ScriptBlock;
                            if (scriptBlock != null)
                                return scriptBlock;
                        }
                    }
                }
            }

            bool isNative = optionKey.Equals("NativeArgumentCompleters", StringComparison.OrdinalIgnoreCase);
            var registeredCompleters = isNative ? context.NativeArgumentCompleters : context.CustomArgumentCompleters;

            if (registeredCompleters != null)
            {
                foreach (var key in keys)

Review comment (suggestion):
I wonder why we evaluate  `isNative` if we could directly pass it as parameter instead of `optionKey`.

Code after:

        private static ScriptBlock GetCustomArgumentCompleter(
            string optionKey,
            IEnumerable<string> keys,
            CompletionContext context)
        {
            ScriptBlock scriptBlock;
            var options = context.Options;
            if (options != null)
            {
                var customCompleters = options[optionKey] as Hashtable;
                if (customCompleters != null)
                {
                    foreach (var key in keys)
                    {
                        if (customCompleters.ContainsKey(key))
                        {
                            scriptBlock = customCompleters[key] as ScriptBlock;
                            if (scriptBlock != null)
                                return scriptBlock;
                        }
                    }
                }
            }

            bool isNative = optionKey.Equals("NativeArgumentCompleters", StringComparison.OrdinalIgnoreCase);
            var registeredCompleters = isNative ? context.NativeArgumentCompleters : context.CustomArgumentCompleters;

            if (registeredCompleters != null)
            {
                foreach (var key in keys)
                {
                    if (registeredCompleters.TryGetValue(key, out scriptBlock))
                    {
                        return scriptBlock;
                    }
                }

                // For a native command, if a fallback completer is registered, then return it.
                // For example, the 'Microsoft.PowerShell.UnixTabCompletion' module.
                if (isNative && registeredCompleters.TryGetValue(RegisterArgumentCompleterCommand.FallbackCompleterKey, out scriptBlock))
                {
                    return scriptBlock;
                }
            }

            return null;
        }

        private static bool InvokeScriptArgumentCompleter(
            ScriptBlock scriptBlock,