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

Code before:
            // Check for method invocation: $PSBoundParameters.ContainsKey('...') or $PSBoundParameters.Remove('...')
            if (lastAst.Parent is InvokeMemberExpressionAst invokeMemberAst)
            {
                var memberName = invokeMemberAst.Member as StringConstantExpressionAst;
                if (memberName != null &&
                    (memberName.Value.Equals("ContainsKey", StringComparison.OrdinalIgnoreCase) ||
                     memberName.Value.Equals("Remove", StringComparison.OrdinalIgnoreCase)))
                {
                    targetAst = invokeMemberAst.Expression;
                }
            }
            // Check for indexer: $PSBoundParameters['...']
            else if (lastAst.Parent is IndexExpressionAst indexAst)
            {
                targetAst = indexAst.Target;
            }

            if (targetAst == null)
            {
                return null;
            }

            // Check if target is $PSBoundParameters
            var variableAst = targetAst as VariableExpressionAst;
            if (variableAst == null ||
                !variableAst.VariablePath.UserPath.Equals("PSBoundParameters", StringComparison.OrdinalIgnoreCase))
            {
                return null;
            }

            // Find the nearest param block
            ParamBlockAst paramBlockAst = null;
            Ast current = lastAst.Parent;
            while (current != null)
            {
                if (current is FunctionDefinitionAst functionDefinitionAst)
                {
                    paramBlockAst = functionDefinitionAst.Body?.ParamBlock;
                    break;
                }
                else if (current is ScriptBlockAst scriptBlockAst)
                {
                    paramBlockAst = scriptBlockAst.ParamBlock;
                    if (paramBlockAst != null)
                    {
                        break;
                    }
                }

                current = current.Parent;
            }

Review comment (suggestion):
```suggestion
            if (targetAst is not VariableExpressionAst variableAst ||
    !variableAst.VariablePath.UserPath.Equals("PSBoundParameters", StringComparison.OrdinalIgnoreCase))
```

Code after:
            // Determine quote style based on the string constant type
            string quoteChar = string.Empty;
            if (stringAst.StringConstantType == StringConstantType.SingleQuoted)
            {
                quoteChar = "'";
            }
            else if (stringAst.StringConstantType == StringConstantType.DoubleQuoted)
            {
                quoteChar = "\"";
            }

            return CreateParameterCompletionResults(paramBlockAst, wordToComplete, quoteChar);
        }

        /// <summary>
        /// Finds the nearest ParamBlockAst by traversing up the AST hierarchy.
        /// </summary>
        /// <param name="startAst">The AST node to start searching from.</param>
        /// <returns>The nearest ParamBlockAst if found; otherwise, null.</returns>
        private static ParamBlockAst FindNearestParamBlock(Ast startAst)
        {
            Ast current = startAst;
            while (current != null)
            {
                if (current is FunctionDefinitionAst functionDefinitionAst)
                {
                    return functionDefinitionAst.Body?.ParamBlock;
                }
                else if (current is ScriptBlockAst scriptBlockAst)
                {
                    var paramBlock = scriptBlockAst.ParamBlock;
                    if (paramBlock != null)
                    {
                        return paramBlock;
                    }
                }

                current = current.Parent;
            }

            return null;
        }

        /// <summary>
        /// Creates completion results from parameter names with optional quote wrapping.
        /// </summary>
        /// <param name="paramBlockAst">The parameter block containing parameters to complete.</param>
        /// <param name="wordToComplete">The partial word to match against parameter names.</param>
        /// <param name="quoteChar">Optional quote character to wrap completion text (empty string for no quotes).</param>
        /// <returns>A list of completion results, or null if no matches found.</returns>
        private static List<CompletionResult> CreateParameterCompletionResults(