-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[release/6.0.3xx] Backport Improve console output of dotnet watch
⌚ (#23318)
#23400
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0abb836
Improve console output of `dotnet watch` ⌚ (#23318)
TanayParikh 21f0b69
UTF8->UTF8 with BOM & UTF8 Console Output Encoding
TanayParikh 319fd07
DOTNET_WATCH_SUPPRESS_EMOJIS
TanayParikh 984613f
Set process encoding
TanayParikh a4eaed8
`dotnet watch` test fix search console history
TanayParikh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Tools.Internal; | ||
|
||
namespace Microsoft.DotNet.Watcher.Tools | ||
{ | ||
public class RudeEditDialog | ||
{ | ||
private readonly IReporter _reporter; | ||
private readonly IRequester _requester; | ||
private readonly IConsole _console; | ||
private bool? _restartImmediatelySessionPreference; // Session preference | ||
|
||
public RudeEditDialog(IReporter reporter, IRequester requester, IConsole console) | ||
{ | ||
_reporter = reporter; | ||
_requester = requester; | ||
_console = console; | ||
|
||
var alwaysRestart = Environment.GetEnvironmentVariable("DOTNET_WATCH_RESTART_ON_RUDE_EDIT"); | ||
|
||
if (alwaysRestart == "1" || string.Equals(alwaysRestart, "true", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
_reporter.Verbose($"DOTNET_WATCH_RESTART_ON_RUDE_EDIT = '{alwaysRestart}'. Restarting without prompt."); | ||
_restartImmediatelySessionPreference = true; | ||
} | ||
} | ||
|
||
public async Task EvaluateAsync(CancellationToken cancellationToken) | ||
{ | ||
if (_restartImmediatelySessionPreference.HasValue) | ||
{ | ||
await GetRudeEditResult(_restartImmediatelySessionPreference.Value, cancellationToken); | ||
return; | ||
} | ||
|
||
var key = await _requester.GetKeyAsync( | ||
"Do you want to restart your app - Yes (y) / No (n) / Always (a) / Never (v)?", | ||
KeyPressed, | ||
cancellationToken); | ||
|
||
switch (key) | ||
{ | ||
case ConsoleKey.Escape: | ||
case ConsoleKey.Y: | ||
await GetRudeEditResult(restartImmediately: true, cancellationToken); | ||
return; | ||
case ConsoleKey.N: | ||
await GetRudeEditResult(restartImmediately: false, cancellationToken); | ||
return; | ||
case ConsoleKey.A: | ||
_restartImmediatelySessionPreference = true; | ||
await GetRudeEditResult(restartImmediately: true, cancellationToken); | ||
return; | ||
case ConsoleKey.V: | ||
_restartImmediatelySessionPreference = false; | ||
await GetRudeEditResult(restartImmediately: false, cancellationToken); | ||
return; | ||
} | ||
|
||
bool KeyPressed(ConsoleKey key) | ||
{ | ||
return key is ConsoleKey.Y or ConsoleKey.N or ConsoleKey.A or ConsoleKey.V; | ||
} | ||
} | ||
|
||
private Task GetRudeEditResult(bool restartImmediately, CancellationToken cancellationToken) | ||
{ | ||
if (restartImmediately) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
_reporter.Output("Hot reload suspended. To continue hot reload, press \"Ctrl + R\".", emoji: "🔥"); | ||
|
||
return Task.Delay(-1, cancellationToken); | ||
} | ||
} | ||
} |
95 changes: 0 additions & 95 deletions
95
src/BuiltInTools/dotnet-watch/HotReload/RudeEditPreference.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.