azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Add ArgumentCompleter to Configuration parameter in BuildModules.ps1

Open Copilot opened this issue 1 month ago • 6 comments

Description

Added [ArgumentCompleter] attribute to the $Configuration parameter in tools/BuildScripts/BuildModules.ps1 to enable tab completion for configuration options.

Changes:

  • Added [ArgumentCompleter] with script block to provide tab completion for "Debug" and "Release" values

Impact:

  • Tab completion now works: -Configuration <TAB> shows Debug/Release options
  • More flexible than ValidateSet - allows future expansion of configuration options without code changes
  • IntelliSense support in IDEs (VS Code, PowerShell ISE)
  • Does not enforce strict validation, allowing custom configuration values if needed

Implementation:

[ArgumentCompleter({
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
    @('Debug', 'Release') | Where-Object { $_ -like "$wordToComplete*" }
})]
[string]$Configuration = 'Debug',

Key Difference from ValidateSet:

  • ArgumentCompleter: Provides tab completion suggestions but allows any value (flexible)
  • ValidateSet: Enforces strict validation and rejects invalid values (restrictive)

Example:

# Valid usage with tab completion
./tools/BuildScripts/BuildModules.ps1 -Configuration Debug -TargetModule Accounts
./tools/BuildScripts/BuildModules.ps1 -Configuration Release -TargetModule Storage

# Tab completion: -Configuration <TAB> shows Debug, Release

Mandatory Checklist

  • Please choose the target release of Azure PowerShell. (⚠️Target release is a different concept from API readiness. Please click below links for details.)

    • [ ] General release
    • [ ] Public preview
    • [ ] Private preview
    • [ ] Engineering build
    • [x] No need for a release
  • [x] Check this box to confirm: I have read the Submitting Changes section of CONTRIBUTING.md and reviewed the following information:

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request
Original prompt

Add an argument completer to the parameter $Configuration of the powershell script tools/BuildScripts/BuildModules.ps1, containing two values "Debug" and "Release".


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Nov 10 '25 00:11 Copilot

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Please make it an argument completer instead of validateset because there might be more options. @copilot

isra-fel avatar Nov 10 '25 01:11 isra-fel

Please make it an argument completer instead of validateset because there might be more options. @copilot

Changed to ArgumentCompleter in commit c387de4. This provides tab completion for "Debug" and "Release" while allowing future expansion of configuration options without requiring code changes to the validation logic.

Copilot avatar Nov 10 '25 01:11 Copilot

/azp run azure-powershell - security-tools

notyashhh avatar Nov 14 '25 03:11 notyashhh

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Nov 14 '25 03:11 azure-pipelines[bot]

@isra-fel Is this PR good to be merged?

notyashhh avatar Nov 18 '25 04:11 notyashhh