Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable --interactive by default for sessions that are local. #47226

Merged

Conversation

baronfel
Copy link
Member

@baronfel baronfel commented Mar 3, 2025

This change unifies the --interactive infrastructure for all dotnet commands. With that common infra, it also enables interactivity for non-CI scenarios by default. We reuse CI detection from telemetry and from output redirection to determine whether to enable interactivity.

Fixes #35165

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Request triage from a team member labels Mar 3, 2025
@baronfel baronfel force-pushed the default-interactive-to-on-for-local-sessions branch from 712f4d8 to cc28c6e Compare March 3, 2025 20:10
@baronfel baronfel force-pushed the default-interactive-to-on-for-local-sessions branch from cc28c6e to 61a448b Compare March 5, 2025 23:38
@baronfel baronfel added Document for new feature cli-ux Issues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on) and removed Area-Infrastructure labels Mar 5, 2025
@baronfel baronfel force-pushed the default-interactive-to-on-for-local-sessions branch 2 times, most recently from 939013b to 6615f0f Compare March 7, 2025 17:13
@baronfel baronfel marked this pull request as ready for review March 7, 2025 19:30
@Copilot Copilot bot review requested due to automatic review settings March 7, 2025 19:30
@baronfel baronfel requested review from tmat, arunchndr and a team as code owners March 7, 2025 19:30
@baronfel baronfel requested a review from a team March 7, 2025 19:30
baronfel added 9 commits March 7, 2025 13:30
This change unifies the `--interactive` infrastructure for all `dotnet` commands.
With that common infra, it also enables interactivity for non-CI scenarios by default.
We reuse CI detection from telemetry and from output redirection to determine whether to enable interactivity.
@baronfel baronfel force-pushed the default-interactive-to-on-for-local-sessions branch from 6615f0f to feb6c94 Compare March 7, 2025 19:30
Copy link
Contributor

@Copilot 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.

PR Overview

This PR unifies the handling of the --interactive option across dotnet CLI commands to enable interactivity by default for local sessions while still allowing it to be explicitly disabled. Key changes include refactoring interactive option definitions to use a common implementation, updating forwarding functions to conditionally include interactive arguments, and adjusting tests to expect the interactive flag in the command arguments.

Reviewed Changes

File Description
src/Cli/dotnet/CommonOptions.cs Introduces helper IsCIEnvironmentOrRedirected() and redefines InteractiveOption to use the new common infra.
test/dotnet-run.Tests/GivenDotnetRunBuildsCsProj.cs Updates tests to reflect that interactivity is enabled by default and adds tests for when it is explicitly disabled.
src/BuiltInTools/dotnet-watch/CommandLineOptions.cs Adjusts forwarding logic to skip the interactive token when --non-interactive is specified.
src/Cli/dotnet/* Updates various command parsers to use the common InteractiveOption implementation.
src/Cli/dotnet/OptionForwardingExtensions.cs Refactors forwarding extension methods to work with nullable values and use a concise array literal syntax.
test/dotnet-watch.Tests/CommandLineOptionsTests.cs Updates test expectations so that interactive defaults are correctly injected into command and build arguments.

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

Comments suppressed due to low confidence (1)

src/Cli/dotnet/OptionForwardingExtensions.cs:14

  • [nitpick] The use of array literal syntax like [option.Name] may reduce clarity for readers; consider using an explicit array initializer (e.g. new string[] { option.Name }) for improved readability.
public static ForwardedOption<T> Forward<T>(this ForwardedOption<T> option) => option.SetForwardingFunction((T? o) => [option.Name]);

@@ -704,6 +704,24 @@ public void ItDoesNotShowImportantLevelMessageByDefault()
.WithWorkingDirectory(testInstance.Path)
.Execute();

// this message should show because interactivity (and therefore nuget auth) is the default
Copy link
Preview

Copilot AI Mar 7, 2025

Choose a reason for hiding this comment

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

The comment in the ItDoesNotShowImportantLevelMessageByDefaultWhenInteractivityDisabled test is misleading because the test name and assertion expect that important level messages are not shown when interactivity is disabled. Please update the comment so it accurately reflects the expected behavior.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Co-authored-by: Michael Yanni <MiYanni@microsoft.com>
@baronfel baronfel enabled auto-merge (squash) March 8, 2025 15:24
@baronfel baronfel merged commit 301a914 into dotnet:main Mar 8, 2025
39 checks passed
@baronfel baronfel deleted the default-interactive-to-on-for-local-sessions branch March 8, 2025 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli-ux Issues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on) Document for new feature untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default --interactive to true across the commands
3 participants