Skip to content

dotnet: set up tab completions for SDK 10+#1596

Open
sliekens wants to merge 2 commits intodevcontainers:mainfrom
sliekens:dotnet-completions
Open

dotnet: set up tab completions for SDK 10+#1596
sliekens wants to merge 2 commits intodevcontainers:mainfrom
sliekens:dotnet-completions

Conversation

@sliekens
Copy link
Contributor

@sliekens sliekens commented Mar 8, 2026

Summary

Set up dotnet tab completions for .NET SDK 10+ installs using the new dotnet completions script command.

Changes

src/dotnet/scripts/dotnet-helpers.sh

  • Added is_at_least_sdk_version helper function that checks if the installed SDK meets a minimum major version threshold. Returns false for runtime-only installs (no SDK available).
  • Added install_completions function that generates completion scripts and drops them into standard system-wide directories:
    • Bash: /usr/share/bash-completion/completions/dotnet
    • Zsh: /usr/share/zsh/site-functions/_dotnet
    • Fish: /usr/share/fish/vendor_completions.d/dotnet.fish

src/dotnet/install.sh

  • Calls install_completions after SDK installation.

Design decisions

  • Gated on SDK 10+: The dotnet completions script command is only available starting with .NET 10. Older versions use a different approach. The version check uses dotnet --version to parse the major version.
  • Runtime-only installs are skipped: When version is set to none, no SDK is installed, and dotnet --version will fail, causing the function to skip gracefully.
  • System-wide completion directories: Completion scripts are placed in the standard directories that bash-completion, zsh, and fish auto-discover. No rc files need to be modified, and completions work for all users including users not yet created.

Reference

https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete

Copilot AI review requested due to automatic review settings March 8, 2026 08:51
@sliekens sliekens requested a review from a team as a code owner March 8, 2026 08:51
@sliekens sliekens force-pushed the dotnet-completions branch 2 times, most recently from a335f8f to 2930611 Compare March 8, 2026 08:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds system-wide tab-completion script installation for .NET SDK 10+ by generating shell completion files via the new dotnet completions script command during feature installation.

Changes:

  • Introduces an SDK-major-version gate helper (is_at_least_sdk_version) to detect SDK 10+ (and skip runtime-only installs).
  • Adds install_completions to generate and install Bash/Zsh/Fish completion scripts into standard system directories.
  • Invokes install_completions from the main .NET feature install script after installing and linking dotnet.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/dotnet/scripts/dotnet-helpers.sh Adds SDK version detection and completion-script generation/installation logic.
src/dotnet/install.sh Calls completion installation after ensuring dotnet is available system-wide.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@sliekens sliekens force-pushed the dotnet-completions branch from 2930611 to b2cb1f4 Compare March 8, 2026 08:57
Generate bash, zsh, and fish completion scripts using 'dotnet completions
script' and place them in the standard system-wide completion directories:
- /usr/share/bash-completion/completions/dotnet
- /usr/share/zsh/site-functions/_dotnet
- /usr/share/fish/vendor_completions.d/dotnet.fish

Gated behind SDK 10+ via version check since the 'dotnet completions script'
command is only available starting with .NET 10. Skipped for runtime-only
installs.

Reference: https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

@Kaniska244 Kaniska244 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sliekens

Thank you for the contribution. I have left couple of comments. Kindly let me know in case of any concern.

  • Please add the new tabCompletions option here
  • Please add test cases for this new option.

@Kaniska244 Kaniska244 self-requested a review March 9, 2026 05:06
Kaniska244
Kaniska244 previously approved these changes Mar 9, 2026
@Kaniska244 Kaniska244 requested a review from abdurriq March 9, 2026 05:07
@sliekens
Copy link
Contributor Author

sliekens commented Mar 9, 2026

Soft blocked by #1597: test.sh checks fail because .NET 10 is required for the tab completion but the feature is stuck on .NET 9.

Prepared a fix in #1598

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants