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

Fix deadlock when cancelling prompts #1439

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

caesay
Copy link
Contributor

@caesay caesay commented Jan 30, 2024

fixes #1077
fixes #1076

Changes

Because ReadKeyAsync returns null if the cancellationToken is cancelled, this creates infinite loops in the AnsiConsoleExtensions.ReadLine method and the ListPrompt.Show method.

@caesay
Copy link
Contributor Author

caesay commented Jan 30, 2024

@microsoft-github-policy-service agree

@caesay
Copy link
Contributor Author

caesay commented Jan 31, 2024

Just as a note here, the check failed because the macOS runner failed to start, not because of the change.

@patriksvensson patriksvensson merged commit 71631b2 into spectreconsole:main Jan 31, 2024
6 checks passed
@patriksvensson
Copy link
Contributor

Merged! Thank you for your contribution. Much appreciated! 👍

renovate bot referenced this pull request in buehler/dotnet-operator-sdk Apr 23, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[Spectre.Console.Testing](https://github.com/spectreconsole/spectre.console)
| `0.48.0` -> `0.49.0` |
[![age](https://developer.mend.io/api/mc/badges/age/nuget/Spectre.Console.Testing/0.49.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/nuget/Spectre.Console.Testing/0.49.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/nuget/Spectre.Console.Testing/0.48.0/0.49.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Spectre.Console.Testing/0.48.0/0.49.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>spectreconsole/spectre.console
(Spectre.Console.Testing)</summary>

###
[`v0.49.0`](https://github.com/spectreconsole/spectre.console/releases/tag/0.49.0)

[Compare
Source](https://github.com/spectreconsole/spectre.console/compare/0.48.0...0.49.0)

##### What's Changed

- Cleanup Line-Endings by [@&#8203;nils-a](https://github.com/nils-a)
in
[https://github.com/spectreconsole/spectre.console/pull/1381](https://github.com/spectreconsole/spectre.console/pull/1381)
- Added spectre.console.cli to quick-start. by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1413](https://github.com/spectreconsole/spectre.console/pull/1413)
- Fix rendering of ListPrompt for odd pageSizes by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1365](https://github.com/spectreconsole/spectre.console/pull/1365)
- Remove mandelbrot example due to conflicting license by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1426](https://github.com/spectreconsole/spectre.console/pull/1426)
- Allow specifying a property to ignore the use of build-time packages
for versioning and analysis by
[@&#8203;baronfel](https://github.com/baronfel) in
[https://github.com/spectreconsole/spectre.console/pull/1425](https://github.com/spectreconsole/spectre.console/pull/1425)
- Add the possibility to register multiple interceptors by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1412](https://github.com/spectreconsole/spectre.console/pull/1412)
- Added the ITypeResolver to the ExceptionHandler by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1411](https://github.com/spectreconsole/spectre.console/pull/1411)
- Updated typo in commandApp.md by
[@&#8203;DarqueWarrior](https://github.com/DarqueWarrior) in
[https://github.com/spectreconsole/spectre.console/pull/1431](https://github.com/spectreconsole/spectre.console/pull/1431)
- Command with -v displays app version instead of executing the command
by [@&#8203;FrankRay78](https://github.com/FrankRay78) in
[https://github.com/spectreconsole/spectre.console/pull/1427](https://github.com/spectreconsole/spectre.console/pull/1427)
- HelpProvider colors should be configurable by
[@&#8203;FrankRay78](https://github.com/FrankRay78) in
[https://github.com/spectreconsole/spectre.console/pull/1408](https://github.com/spectreconsole/spectre.console/pull/1408)
- Direct contributors to the current CONTRIBUTING.md by
[@&#8203;tonycknight](https://github.com/tonycknight) in
[https://github.com/spectreconsole/spectre.console/pull/1435](https://github.com/spectreconsole/spectre.console/pull/1435)
- Fix deadlock when cancelling prompts by
[@&#8203;caesay](https://github.com/caesay) in
[https://github.com/spectreconsole/spectre.console/pull/1439](https://github.com/spectreconsole/spectre.console/pull/1439)
- Add progress bar value formatter by
[@&#8203;jsheely](https://github.com/jsheely) in
[https://github.com/spectreconsole/spectre.console/pull/1414](https://github.com/spectreconsole/spectre.console/pull/1414)
- Update dependencies and do some clean-up by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1440](https://github.com/spectreconsole/spectre.console/pull/1440)
- Delete \[UsesVerify], which has become obsolete through the latest
update. by [@&#8203;danielcweber](https://github.com/danielcweber) in
[https://github.com/spectreconsole/spectre.console/pull/1456](https://github.com/spectreconsole/spectre.console/pull/1456)
- Don't erase secret prompt text upon backspace when mask is null by
[@&#8203;danielcweber](https://github.com/danielcweber) in
[https://github.com/spectreconsole/spectre.console/pull/1458](https://github.com/spectreconsole/spectre.console/pull/1458)
- Update dependencies to the latest version by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1459](https://github.com/spectreconsole/spectre.console/pull/1459)
- Automatically register command settings by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1463](https://github.com/spectreconsole/spectre.console/pull/1463)
- chore: Update dependency dotnet-example to v3.1.0 by
[@&#8203;renovate](https://github.com/renovate) in
[https://github.com/spectreconsole/spectre.console/pull/1470](https://github.com/spectreconsole/spectre.console/pull/1470)
- chore: Update dependency Roslynator.Analyzers to v4.11.0 by
[@&#8203;renovate](https://github.com/renovate) in
[https://github.com/spectreconsole/spectre.console/pull/1473](https://github.com/spectreconsole/spectre.console/pull/1473)
- Remove \[DebuggerDisplay] from Paragraph by
[@&#8203;martincostello](https://github.com/martincostello) in
[https://github.com/spectreconsole/spectre.console/pull/1477](https://github.com/spectreconsole/spectre.console/pull/1477)
- Selection Prompt Search by
[@&#8203;slang25](https://github.com/slang25) in
[https://github.com/spectreconsole/spectre.console/pull/1289](https://github.com/spectreconsole/spectre.console/pull/1289)
- Update dependency SixLabors.ImageSharp to v3.1.3 by
[@&#8203;renovate](https://github.com/renovate) in
[https://github.com/spectreconsole/spectre.console/pull/1486](https://github.com/spectreconsole/spectre.console/pull/1486)
- Positioned Progress Tasks - Before or After Other Tasks by
[@&#8203;thomhurst](https://github.com/thomhurst) in
[https://github.com/spectreconsole/spectre.console/pull/1250](https://github.com/spectreconsole/spectre.console/pull/1250)
- Added NoStackTrace to ExceptionFormats by
[@&#8203;gerardog](https://github.com/gerardog) in
[https://github.com/spectreconsole/spectre.console/pull/1489](https://github.com/spectreconsole/spectre.console/pull/1489)
- Pipe character for listing options (issue 1434) by
[@&#8203;FrankRay78](https://github.com/FrankRay78) in
[https://github.com/spectreconsole/spectre.console/pull/1498](https://github.com/spectreconsole/spectre.console/pull/1498)
- Improve XmlDoc output by
[@&#8203;yenneferofvengerberg](https://github.com/yenneferofvengerberg)
in
[https://github.com/spectreconsole/spectre.console/pull/1503](https://github.com/spectreconsole/spectre.console/pull/1503)
- Revert
[`71a5d83`](https://github.com/spectreconsole/spectre.console/commit/71a5d830)
to undo flickering regression by
[@&#8203;phil-scott-78](https://github.com/phil-scott-78) in
[https://github.com/spectreconsole/spectre.console/pull/1504](https://github.com/spectreconsole/spectre.console/pull/1504)
- AddDelegate uses an abstract type when used in a branch by
[@&#8203;BlazeFace](https://github.com/BlazeFace) in
[https://github.com/spectreconsole/spectre.console/pull/1509](https://github.com/spectreconsole/spectre.console/pull/1509)
- Missing Separator When Headers are Hidden by
[@&#8203;BlazeFace](https://github.com/BlazeFace) in
[https://github.com/spectreconsole/spectre.console/pull/1513](https://github.com/spectreconsole/spectre.console/pull/1513)
- Expose raw arguments on the command context by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1523](https://github.com/spectreconsole/spectre.console/pull/1523)
- Add token representation to remaining arguments by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1525](https://github.com/spectreconsole/spectre.console/pull/1525)

##### New Contributors

- [@&#8203;baronfel](https://github.com/baronfel) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1425](https://github.com/spectreconsole/spectre.console/pull/1425)
- [@&#8203;DarqueWarrior](https://github.com/DarqueWarrior) made their
first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1431](https://github.com/spectreconsole/spectre.console/pull/1431)
- [@&#8203;tonycknight](https://github.com/tonycknight) made their
first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1435](https://github.com/spectreconsole/spectre.console/pull/1435)
- [@&#8203;caesay](https://github.com/caesay) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1439](https://github.com/spectreconsole/spectre.console/pull/1439)
- [@&#8203;jsheely](https://github.com/jsheely) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1414](https://github.com/spectreconsole/spectre.console/pull/1414)
- [@&#8203;danielcweber](https://github.com/danielcweber) made their
first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1456](https://github.com/spectreconsole/spectre.console/pull/1456)
- [@&#8203;martincostello](https://github.com/martincostello) made
their first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1477](https://github.com/spectreconsole/spectre.console/pull/1477)
- [@&#8203;slang25](https://github.com/slang25) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1289](https://github.com/spectreconsole/spectre.console/pull/1289)
- [@&#8203;thomhurst](https://github.com/thomhurst) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1250](https://github.com/spectreconsole/spectre.console/pull/1250)
- [@&#8203;gerardog](https://github.com/gerardog) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1489](https://github.com/spectreconsole/spectre.console/pull/1489)
-
[@&#8203;yenneferofvengerberg](https://github.com/yenneferofvengerberg)
made their first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1503](https://github.com/spectreconsole/spectre.console/pull/1503)
- [@&#8203;BlazeFace](https://github.com/BlazeFace) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1509](https://github.com/spectreconsole/spectre.console/pull/1509)

**Full Changelog**:
spectreconsole/spectre.console@0.48.0...0.49.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 9pm,before 6am" in timezone
Europe/Zurich, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/buehler/dotnet-operator-sdk).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMTMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjMxMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
ian-buse referenced this pull request in dh2i-devs/dotnet-operator-sdk May 3, 2024
…ehler#751)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[Spectre.Console.Testing](https://github.com/spectreconsole/spectre.console)
| `0.48.0` -> `0.49.0` |
[![age](https://developer.mend.io/api/mc/badges/age/nuget/Spectre.Console.Testing/0.49.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/nuget/Spectre.Console.Testing/0.49.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/nuget/Spectre.Console.Testing/0.48.0/0.49.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Spectre.Console.Testing/0.48.0/0.49.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>spectreconsole/spectre.console
(Spectre.Console.Testing)</summary>

###
[`v0.49.0`](https://github.com/spectreconsole/spectre.console/releases/tag/0.49.0)

[Compare
Source](https://github.com/spectreconsole/spectre.console/compare/0.48.0...0.49.0)

##### What's Changed

- Cleanup Line-Endings by [@&#8203;nils-a](https://github.com/nils-a)
in
[https://github.com/spectreconsole/spectre.console/pull/1381](https://github.com/spectreconsole/spectre.console/pull/1381)
- Added spectre.console.cli to quick-start. by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1413](https://github.com/spectreconsole/spectre.console/pull/1413)
- Fix rendering of ListPrompt for odd pageSizes by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1365](https://github.com/spectreconsole/spectre.console/pull/1365)
- Remove mandelbrot example due to conflicting license by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1426](https://github.com/spectreconsole/spectre.console/pull/1426)
- Allow specifying a property to ignore the use of build-time packages
for versioning and analysis by
[@&#8203;baronfel](https://github.com/baronfel) in
[https://github.com/spectreconsole/spectre.console/pull/1425](https://github.com/spectreconsole/spectre.console/pull/1425)
- Add the possibility to register multiple interceptors by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1412](https://github.com/spectreconsole/spectre.console/pull/1412)
- Added the ITypeResolver to the ExceptionHandler by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1411](https://github.com/spectreconsole/spectre.console/pull/1411)
- Updated typo in commandApp.md by
[@&#8203;DarqueWarrior](https://github.com/DarqueWarrior) in
[https://github.com/spectreconsole/spectre.console/pull/1431](https://github.com/spectreconsole/spectre.console/pull/1431)
- Command with -v displays app version instead of executing the command
by [@&#8203;FrankRay78](https://github.com/FrankRay78) in
[https://github.com/spectreconsole/spectre.console/pull/1427](https://github.com/spectreconsole/spectre.console/pull/1427)
- HelpProvider colors should be configurable by
[@&#8203;FrankRay78](https://github.com/FrankRay78) in
[https://github.com/spectreconsole/spectre.console/pull/1408](https://github.com/spectreconsole/spectre.console/pull/1408)
- Direct contributors to the current CONTRIBUTING.md by
[@&#8203;tonycknight](https://github.com/tonycknight) in
[https://github.com/spectreconsole/spectre.console/pull/1435](https://github.com/spectreconsole/spectre.console/pull/1435)
- Fix deadlock when cancelling prompts by
[@&#8203;caesay](https://github.com/caesay) in
[https://github.com/spectreconsole/spectre.console/pull/1439](https://github.com/spectreconsole/spectre.console/pull/1439)
- Add progress bar value formatter by
[@&#8203;jsheely](https://github.com/jsheely) in
[https://github.com/spectreconsole/spectre.console/pull/1414](https://github.com/spectreconsole/spectre.console/pull/1414)
- Update dependencies and do some clean-up by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1440](https://github.com/spectreconsole/spectre.console/pull/1440)
- Delete \[UsesVerify], which has become obsolete through the latest
update. by [@&#8203;danielcweber](https://github.com/danielcweber) in
[https://github.com/spectreconsole/spectre.console/pull/1456](https://github.com/spectreconsole/spectre.console/pull/1456)
- Don't erase secret prompt text upon backspace when mask is null by
[@&#8203;danielcweber](https://github.com/danielcweber) in
[https://github.com/spectreconsole/spectre.console/pull/1458](https://github.com/spectreconsole/spectre.console/pull/1458)
- Update dependencies to the latest version by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1459](https://github.com/spectreconsole/spectre.console/pull/1459)
- Automatically register command settings by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1463](https://github.com/spectreconsole/spectre.console/pull/1463)
- chore: Update dependency dotnet-example to v3.1.0 by
[@&#8203;renovate](https://github.com/renovate) in
[https://github.com/spectreconsole/spectre.console/pull/1470](https://github.com/spectreconsole/spectre.console/pull/1470)
- chore: Update dependency Roslynator.Analyzers to v4.11.0 by
[@&#8203;renovate](https://github.com/renovate) in
[https://github.com/spectreconsole/spectre.console/pull/1473](https://github.com/spectreconsole/spectre.console/pull/1473)
- Remove \[DebuggerDisplay] from Paragraph by
[@&#8203;martincostello](https://github.com/martincostello) in
[https://github.com/spectreconsole/spectre.console/pull/1477](https://github.com/spectreconsole/spectre.console/pull/1477)
- Selection Prompt Search by
[@&#8203;slang25](https://github.com/slang25) in
[https://github.com/spectreconsole/spectre.console/pull/1289](https://github.com/spectreconsole/spectre.console/pull/1289)
- Update dependency SixLabors.ImageSharp to v3.1.3 by
[@&#8203;renovate](https://github.com/renovate) in
[https://github.com/spectreconsole/spectre.console/pull/1486](https://github.com/spectreconsole/spectre.console/pull/1486)
- Positioned Progress Tasks - Before or After Other Tasks by
[@&#8203;thomhurst](https://github.com/thomhurst) in
[https://github.com/spectreconsole/spectre.console/pull/1250](https://github.com/spectreconsole/spectre.console/pull/1250)
- Added NoStackTrace to ExceptionFormats by
[@&#8203;gerardog](https://github.com/gerardog) in
[https://github.com/spectreconsole/spectre.console/pull/1489](https://github.com/spectreconsole/spectre.console/pull/1489)
- Pipe character for listing options (issue 1434) by
[@&#8203;FrankRay78](https://github.com/FrankRay78) in
[https://github.com/spectreconsole/spectre.console/pull/1498](https://github.com/spectreconsole/spectre.console/pull/1498)
- Improve XmlDoc output by
[@&#8203;yenneferofvengerberg](https://github.com/yenneferofvengerberg)
in
[https://github.com/spectreconsole/spectre.console/pull/1503](https://github.com/spectreconsole/spectre.console/pull/1503)
- Revert
[`71a5d83`](https://github.com/spectreconsole/spectre.console/commit/71a5d830)
to undo flickering regression by
[@&#8203;phil-scott-78](https://github.com/phil-scott-78) in
[https://github.com/spectreconsole/spectre.console/pull/1504](https://github.com/spectreconsole/spectre.console/pull/1504)
- AddDelegate uses an abstract type when used in a branch by
[@&#8203;BlazeFace](https://github.com/BlazeFace) in
[https://github.com/spectreconsole/spectre.console/pull/1509](https://github.com/spectreconsole/spectre.console/pull/1509)
- Missing Separator When Headers are Hidden by
[@&#8203;BlazeFace](https://github.com/BlazeFace) in
[https://github.com/spectreconsole/spectre.console/pull/1513](https://github.com/spectreconsole/spectre.console/pull/1513)
- Expose raw arguments on the command context by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1523](https://github.com/spectreconsole/spectre.console/pull/1523)
- Add token representation to remaining arguments by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1525](https://github.com/spectreconsole/spectre.console/pull/1525)

##### New Contributors

- [@&#8203;baronfel](https://github.com/baronfel) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1425](https://github.com/spectreconsole/spectre.console/pull/1425)
- [@&#8203;DarqueWarrior](https://github.com/DarqueWarrior) made their
first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1431](https://github.com/spectreconsole/spectre.console/pull/1431)
- [@&#8203;tonycknight](https://github.com/tonycknight) made their
first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1435](https://github.com/spectreconsole/spectre.console/pull/1435)
- [@&#8203;caesay](https://github.com/caesay) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1439](https://github.com/spectreconsole/spectre.console/pull/1439)
- [@&#8203;jsheely](https://github.com/jsheely) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1414](https://github.com/spectreconsole/spectre.console/pull/1414)
- [@&#8203;danielcweber](https://github.com/danielcweber) made their
first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1456](https://github.com/spectreconsole/spectre.console/pull/1456)
- [@&#8203;martincostello](https://github.com/martincostello) made
their first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1477](https://github.com/spectreconsole/spectre.console/pull/1477)
- [@&#8203;slang25](https://github.com/slang25) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1289](https://github.com/spectreconsole/spectre.console/pull/1289)
- [@&#8203;thomhurst](https://github.com/thomhurst) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1250](https://github.com/spectreconsole/spectre.console/pull/1250)
- [@&#8203;gerardog](https://github.com/gerardog) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1489](https://github.com/spectreconsole/spectre.console/pull/1489)
-
[@&#8203;yenneferofvengerberg](https://github.com/yenneferofvengerberg)
made their first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1503](https://github.com/spectreconsole/spectre.console/pull/1503)
- [@&#8203;BlazeFace](https://github.com/BlazeFace) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1509](https://github.com/spectreconsole/spectre.console/pull/1509)

**Full Changelog**:
spectreconsole/spectre.console@0.48.0...0.49.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 9pm,before 6am" in timezone
Europe/Zurich, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/buehler/dotnet-operator-sdk).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMTMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjMxMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
vgmello referenced this pull request in ellosoft/aws-cred-mgr May 31, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[Spectre.Console.Analyzer](https://github.com/spectreconsole/spectre.console)
| `0.48.0` -> `0.49.1` |
[![age](https://developer.mend.io/api/mc/badges/age/nuget/Spectre.Console.Analyzer/0.49.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/nuget/Spectre.Console.Analyzer/0.49.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/nuget/Spectre.Console.Analyzer/0.48.0/0.49.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Spectre.Console.Analyzer/0.48.0/0.49.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[Spectre.Console.Cli](https://github.com/spectreconsole/spectre.console)
| `0.48.0` -> `0.49.1` |
[![age](https://developer.mend.io/api/mc/badges/age/nuget/Spectre.Console.Cli/0.49.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/nuget/Spectre.Console.Cli/0.49.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/nuget/Spectre.Console.Cli/0.48.0/0.49.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Spectre.Console.Cli/0.48.0/0.49.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>spectreconsole/spectre.console
(Spectre.Console.Analyzer)</summary>

###
[`v0.49.1`](https://github.com/spectreconsole/spectre.console/compare/0.49.0...0.49.1)

[Compare
Source](https://github.com/spectreconsole/spectre.console/compare/0.49.0...0.49.1)

###
[`v0.49.0`](https://github.com/spectreconsole/spectre.console/releases/tag/0.49.0)

[Compare
Source](https://github.com/spectreconsole/spectre.console/compare/0.48.0...0.49.0)

#### What's Changed

- Cleanup line endings by [@&#8203;nils-a](https://github.com/nils-a)
in
[https://github.com/spectreconsole/spectre.console/pull/1381](https://github.com/spectreconsole/spectre.console/pull/1381)
- Added Spectre.Console.Cli to quick-start. by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1413](https://github.com/spectreconsole/spectre.console/pull/1413)
- Fix rendering of ListPrompt for odd pageSizes by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1365](https://github.com/spectreconsole/spectre.console/pull/1365)
- Remove mandelbrot example due to conflicting license by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1426](https://github.com/spectreconsole/spectre.console/pull/1426)
- Allow specifying a property to ignore the use of build-time packages
for versioning and analysis by
[@&#8203;baronfel](https://github.com/baronfel) in
[https://github.com/spectreconsole/spectre.console/pull/1425](https://github.com/spectreconsole/spectre.console/pull/1425)
- Add the possibility to register multiple interceptors by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1412](https://github.com/spectreconsole/spectre.console/pull/1412)
- Added the ITypeResolver to the ExceptionHandler by
[@&#8203;nils-a](https://github.com/nils-a) in
[https://github.com/spectreconsole/spectre.console/pull/1411](https://github.com/spectreconsole/spectre.console/pull/1411)
- Updated typo in CommandApp.md by
[@&#8203;DarqueWarrior](https://github.com/DarqueWarrior) in
[https://github.com/spectreconsole/spectre.console/pull/1431](https://github.com/spectreconsole/spectre.console/pull/1431)
- Command with -v displays app version instead of executing the command
by [@&#8203;FrankRay78](https://github.com/FrankRay78) in
[https://github.com/spectreconsole/spectre.console/pull/1427](https://github.com/spectreconsole/spectre.console/pull/1427)
- HelpProvider colors should be configurable by
[@&#8203;FrankRay78](https://github.com/FrankRay78) in
[https://github.com/spectreconsole/spectre.console/pull/1408](https://github.com/spectreconsole/spectre.console/pull/1408)
- Direct contributors to the current CONTRIBUTING.md by
[@&#8203;tonycknight](https://github.com/tonycknight) in
[https://github.com/spectreconsole/spectre.console/pull/1435](https://github.com/spectreconsole/spectre.console/pull/1435)
- Fix deadlock when cancelling prompts by
[@&#8203;caesay](https://github.com/caesay) in
[https://github.com/spectreconsole/spectre.console/pull/1439](https://github.com/spectreconsole/spectre.console/pull/1439)
- Add progress bar value formatter by
[@&#8203;jsheely](https://github.com/jsheely) in
[https://github.com/spectreconsole/spectre.console/pull/1414](https://github.com/spectreconsole/spectre.console/pull/1414)
- Update dependencies and do some clean-up by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1440](https://github.com/spectreconsole/spectre.console/pull/1440)
- Delete \[UsesVerify], which has become obsolete through the latest
update. by [@&#8203;danielcweber](https://github.com/danielcweber) in
[https://github.com/spectreconsole/spectre.console/pull/1456](https://github.com/spectreconsole/spectre.console/pull/1456)
- Don't erase secret prompt text upon backspace when mask is null by
[@&#8203;danielcweber](https://github.com/danielcweber) in
[https://github.com/spectreconsole/spectre.console/pull/1458](https://github.com/spectreconsole/spectre.console/pull/1458)
- Update dependencies to the latest version by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1459](https://github.com/spectreconsole/spectre.console/pull/1459)
- Automatically register command settings by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1463](https://github.com/spectreconsole/spectre.console/pull/1463)
- Remove \[DebuggerDisplay] from Paragraph by
[@&#8203;martincostello](https://github.com/martincostello) in
[https://github.com/spectreconsole/spectre.console/pull/1477](https://github.com/spectreconsole/spectre.console/pull/1477)
- Selection Prompt Search by
[@&#8203;slang25](https://github.com/slang25) in
[https://github.com/spectreconsole/spectre.console/pull/1289](https://github.com/spectreconsole/spectre.console/pull/1289)
- Update dependency SixLabors.ImageSharp to v3.1.3 by
[@&#8203;renovate](https://github.com/renovate) in
[https://github.com/spectreconsole/spectre.console/pull/1486](https://github.com/spectreconsole/spectre.console/pull/1486)
- Positioned Progress Tasks - Before or After Other Tasks by
[@&#8203;thomhurst](https://github.com/thomhurst) in
[https://github.com/spectreconsole/spectre.console/pull/1250](https://github.com/spectreconsole/spectre.console/pull/1250)
- Added NoStackTrace to ExceptionFormats by
[@&#8203;gerardog](https://github.com/gerardog) in
[https://github.com/spectreconsole/spectre.console/pull/1489](https://github.com/spectreconsole/spectre.console/pull/1489)
- Pipe character for listing options (issue 1434) by
[@&#8203;FrankRay78](https://github.com/FrankRay78) in
[https://github.com/spectreconsole/spectre.console/pull/1498](https://github.com/spectreconsole/spectre.console/pull/1498)
- Improve XmlDoc output by
[@&#8203;yenneferofvengerberg](https://github.com/yenneferofvengerberg)
in
[https://github.com/spectreconsole/spectre.console/pull/1503](https://github.com/spectreconsole/spectre.console/pull/1503)
- Revert
[`71a5d83`](https://github.com/spectreconsole/spectre.console/commit/71a5d830)
to undo flickering regression by
[@&#8203;phil-scott-78](https://github.com/phil-scott-78) in
[https://github.com/spectreconsole/spectre.console/pull/1504](https://github.com/spectreconsole/spectre.console/pull/1504)
- AddDelegate uses an abstract type when used in a branch by
[@&#8203;BlazeFace](https://github.com/BlazeFace) in
[https://github.com/spectreconsole/spectre.console/pull/1509](https://github.com/spectreconsole/spectre.console/pull/1509)
- Missing Separator When Headers are Hidden by
[@&#8203;BlazeFace](https://github.com/BlazeFace) in
[https://github.com/spectreconsole/spectre.console/pull/1513](https://github.com/spectreconsole/spectre.console/pull/1513)
- Expose raw arguments on the command context by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1523](https://github.com/spectreconsole/spectre.console/pull/1523)
- Add token representation to remaining arguments by
[@&#8203;patriksvensson](https://github.com/patriksvensson) in
[https://github.com/spectreconsole/spectre.console/pull/1525](https://github.com/spectreconsole/spectre.console/pull/1525)

#### New Contributors

- [@&#8203;baronfel](https://github.com/baronfel) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1425](https://github.com/spectreconsole/spectre.console/pull/1425)
- [@&#8203;DarqueWarrior](https://github.com/DarqueWarrior) made their
first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1431](https://github.com/spectreconsole/spectre.console/pull/1431)
- [@&#8203;tonycknight](https://github.com/tonycknight) made their
first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1435](https://github.com/spectreconsole/spectre.console/pull/1435)
- [@&#8203;caesay](https://github.com/caesay) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1439](https://github.com/spectreconsole/spectre.console/pull/1439)
- [@&#8203;jsheely](https://github.com/jsheely) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1414](https://github.com/spectreconsole/spectre.console/pull/1414)
- [@&#8203;danielcweber](https://github.com/danielcweber) made their
first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1456](https://github.com/spectreconsole/spectre.console/pull/1456)
- [@&#8203;martincostello](https://github.com/martincostello) made
their first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1477](https://github.com/spectreconsole/spectre.console/pull/1477)
- [@&#8203;slang25](https://github.com/slang25) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1289](https://github.com/spectreconsole/spectre.console/pull/1289)
- [@&#8203;thomhurst](https://github.com/thomhurst) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1250](https://github.com/spectreconsole/spectre.console/pull/1250)
- [@&#8203;gerardog](https://github.com/gerardog) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1489](https://github.com/spectreconsole/spectre.console/pull/1489)
-
[@&#8203;yenneferofvengerberg](https://github.com/yenneferofvengerberg)
made their first contribution in
[https://github.com/spectreconsole/spectre.console/pull/1503](https://github.com/spectreconsole/spectre.console/pull/1503)
- [@&#8203;BlazeFace](https://github.com/BlazeFace) made their first
contribution in
[https://github.com/spectreconsole/spectre.console/pull/1509](https://github.com/spectreconsole/spectre.console/pull/1509)

**Full Changelog**:
spectreconsole/spectre.console@0.48.0...0.49.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/ellosoft/aws-cred-mgr).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMTMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjMyMS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
0xced added a commit to 0xced/spectre.console that referenced this pull request Sep 10, 2024
The current prompt APIs suffer from several problems.

First, the prompt APIs are fundamentally synchronous APIs. If we get down to the underlying implementation of all the prompt APIs, i.e. the `DefaultInput` class we can see some issues.

Here's are the problematic implementation (before this commit fixes it):

```csharp
public ConsoleKeyInfo? ReadKey(bool intercept)
{
    return System.Console.ReadKey(intercept);
}

public async Task<ConsoleKeyInfo?> ReadKeyAsync(bool intercept, CancellationToken cancellationToken)
{
    while (true)
    {
        if (cancellationToken.IsCancellationRequested)
        {
            return null;
        }

        if (System.Console.KeyAvailable)
        {
            break;
        }

        await Task.Delay(5, cancellationToken).ConfigureAwait(false);
    }

    return ReadKey(intercept);
}
```

* The syncrhonous `ReadKey` method returns a nullable `ConsoleKeyInfo` struct but `System.Console.ReadKey` can never return a nullable `ConsoleKeyInfo`.
* The asyncrhonous `ReadKeyAsync` method can return `null` only if cancellation has been requested. But this can never actually happen since [Fix deadlock when cancelling prompts (spectreconsole#1439)](spectreconsole#1439) was merged.
* The asyncrhonous `ReadKeyAsync` method is not actually an synchronous method, it's waiting for a key to be pressed in a loop, waiting 5 milliseconds before checking again if it can break out of the loop.

The proposed fix obsoletes the `ReadKeyAsync` method and add cancellation support to the synchronous `ReadKey` method through an optional  `CancellationToken`. It also returns a non-nullable `ConsoleKeyInfo` making it clear that the only way to get out of this method is through cancellation. Then this change bubbles up to all the prompt APIs, also obsoleting the `IPrompt.ShowAsync` methods.

This is a better alternative to [Async overloads for AnsiConsole Prompt/Ask/Confirm (spectreconsole#1194)](spectreconsole#1194) where the actual need is having a `CancellationToken` to perform some cleanup and not having async prompt APIs.

Note that this is a breaking change since it modifies the signatures of the public `IAnsiConsoleInput` interface but that should not be an issue since it's impossible to use another implentation than `DefaultInput` when used through `AnsiConsole.Create(AnsiConsoleSettings settings)`.  

I have also searched for [implementers of IAnsiConsoleInput](https://grep.app/search?q=IAnsiConsoleInput) and I think this change won't break anything since nobody actually implemented `IAnsiConsoleInput`. Only exising implementations which have been udated are being used (at least across a half million public git repos).
0xced added a commit to 0xced/spectre.console that referenced this pull request Sep 10, 2024
The current prompt APIs suffer from several problems.

First, the prompt APIs are fundamentally synchronous APIs. If we get down to the underlying implementation of all the prompt APIs, i.e. the `DefaultInput` class we can see some issues.

Here's are the problematic implementation (before this commit fixes it):

```csharp
public ConsoleKeyInfo? ReadKey(bool intercept)
{
    return System.Console.ReadKey(intercept);
}

public async Task<ConsoleKeyInfo?> ReadKeyAsync(bool intercept, CancellationToken cancellationToken)
{
    while (true)
    {
        if (cancellationToken.IsCancellationRequested)
        {
            return null;
        }

        if (System.Console.KeyAvailable)
        {
            break;
        }

        await Task.Delay(5, cancellationToken).ConfigureAwait(false);
    }

    return ReadKey(intercept);
}
```

* The syncrhonous `ReadKey` method returns a nullable `ConsoleKeyInfo` struct but `System.Console.ReadKey` can never return a nullable `ConsoleKeyInfo`.
* The asyncrhonous `ReadKeyAsync` method can return `null` only if cancellation has been requested. But this can never actually happen since [Fix deadlock when cancelling prompts (spectreconsole#1439)](spectreconsole#1439) was merged.
* The asyncrhonous `ReadKeyAsync` method is not actually an synchronous method, it's waiting for a key to be pressed in a loop, waiting 5 milliseconds before checking again if it can break out of the loop.

The proposed fix obsoletes the `ReadKeyAsync` method and add cancellation support to the synchronous `ReadKey` method through an optional  `CancellationToken`. It also returns a non-nullable `ConsoleKeyInfo` making it clear that the only way to get out of this method is through cancellation. Then this change bubbles up to all the prompt APIs, also obsoleting the `IPrompt.ShowAsync` methods.

This is a better alternative to [Async overloads for AnsiConsole Prompt/Ask/Confirm (spectreconsole#1194)](spectreconsole#1194) where the actual need is having a `CancellationToken` to perform some cleanup and not having async prompt APIs.

Note that this is a breaking change since it modifies the signatures of the public `IAnsiConsoleInput` interface but that should not be an issue since it's impossible to use another implentation than `DefaultInput` when used through `AnsiConsole.Create(AnsiConsoleSettings settings)`.  

I have also searched for [implementers of IAnsiConsoleInput](https://grep.app/search?q=IAnsiConsoleInput) and I think this change won't break anything since nobody actually implemented `IAnsiConsoleInput`. Only exising implementations which have been udated are being used (at least across a half million public git repos).

The addition of the `CancellationToken` to `IPrompt.Show(IAnsiConsole console, CancellationToken cancellationToken = default)` is also a breaking change but it should be mitigated since it has bee introduced with a default value.
0xced added a commit to 0xced/spectre.console that referenced this pull request Sep 10, 2024
The current prompt APIs suffer from several problems.

First, the prompt APIs are fundamentally synchronous APIs. If we get down to the underlying implementation of all the prompt APIs, i.e. the `DefaultInput` class we can see some issues.

Here's are the problematic implementation (before this commit fixes it):

```csharp
public ConsoleKeyInfo? ReadKey(bool intercept)
{
    return System.Console.ReadKey(intercept);
}

public async Task<ConsoleKeyInfo?> ReadKeyAsync(bool intercept, CancellationToken cancellationToken)
{
    while (true)
    {
        if (cancellationToken.IsCancellationRequested)
        {
            return null;
        }

        if (System.Console.KeyAvailable)
        {
            break;
        }

        await Task.Delay(5, cancellationToken).ConfigureAwait(false);
    }

    return ReadKey(intercept);
}
```

* The syncrhonous `ReadKey` method returns a nullable `ConsoleKeyInfo` struct but `System.Console.ReadKey` can never return a nullable `ConsoleKeyInfo`.
* The asyncrhonous `ReadKeyAsync` method can return `null` only if cancellation has been requested. But this can never actually happen since [Fix deadlock when cancelling prompts (spectreconsole#1439)](spectreconsole#1439) was merged.
* The asyncrhonous `ReadKeyAsync` method is not actually an synchronous method, it's waiting for a key to be pressed in a loop, waiting 5 milliseconds before checking again if it can break out of the loop.

The proposed fix obsoletes the `ReadKeyAsync` method and add cancellation support to the synchronous `ReadKey` method through an optional  `CancellationToken`. It also returns a non-nullable `ConsoleKeyInfo` making it clear that the only way to get out of this method is through cancellation. Then this change bubbles up to all the prompt APIs, also obsoleting the `IPrompt.ShowAsync` methods.

This is a better alternative to [Async overloads for AnsiConsole Prompt/Ask/Confirm (spectreconsole#1194)](spectreconsole#1194) where the actual need is having a `CancellationToken` to perform some cleanup and not having async prompt APIs.

Note that this is a breaking change since it modifies the signatures of the public `IAnsiConsoleInput` interface but that should not be an issue since it's impossible to use another implentation than `DefaultInput` when used through `AnsiConsole.Create(AnsiConsoleSettings settings)`.  

I have also searched for [implementers of IAnsiConsoleInput](https://grep.app/search?q=IAnsiConsoleInput) and I think this change won't break anything since nobody actually implemented `IAnsiConsoleInput`. Only exising implementations which have been udated are being used (at least across a half million public git repos).

The addition of the `CancellationToken` to `IPrompt.Show(IAnsiConsole console, CancellationToken cancellationToken = default)` is also a breaking change but it should be mitigated since it has bee introduced with a default value.
0xced added a commit to 0xced/spectre.console that referenced this pull request Sep 10, 2024
The current prompt APIs suffer from several problems.

First, the prompt APIs are fundamentally synchronous APIs. If we get down to the underlying implementation of all the prompt APIs, i.e. the `DefaultInput` class we can see some issues.

Here's are the problematic implementation (before this commit fixes it):

```csharp
public ConsoleKeyInfo? ReadKey(bool intercept)
{
    return System.Console.ReadKey(intercept);
}

public async Task<ConsoleKeyInfo?> ReadKeyAsync(bool intercept, CancellationToken cancellationToken)
{
    while (true)
    {
        if (cancellationToken.IsCancellationRequested)
        {
            return null;
        }

        if (System.Console.KeyAvailable)
        {
            break;
        }

        await Task.Delay(5, cancellationToken).ConfigureAwait(false);
    }

    return ReadKey(intercept);
}
```

* The syncrhonous `ReadKey` method returns a nullable `ConsoleKeyInfo` struct but `System.Console.ReadKey` can never return a nullable `ConsoleKeyInfo`.
* The asyncrhonous `ReadKeyAsync` method can return `null` only if cancellation has been requested. But this can never actually happen since [Fix deadlock when cancelling prompts (spectreconsole#1439)](spectreconsole#1439) was merged.
* The asyncrhonous `ReadKeyAsync` method is not actually an synchronous method, it's waiting for a key to be pressed in a loop, waiting 5 milliseconds before checking again if it can break out of the loop.

The proposed fix obsoletes the `ReadKeyAsync` method and add cancellation support to the synchronous `ReadKey` method through an optional  `CancellationToken`. It also returns a non-nullable `ConsoleKeyInfo` making it clear that the only way to get out of this method is through cancellation. Then this change bubbles up to all the prompt APIs, also obsoleting the `IPrompt.ShowAsync` methods.

This is a better alternative to [Async overloads for AnsiConsole Prompt/Ask/Confirm (spectreconsole#1194)](spectreconsole#1194) where the actual need is having a `CancellationToken` to perform some cleanup and not having async prompt APIs.

Note that this is a breaking change since it modifies the signatures of the public `IAnsiConsoleInput` interface but that should not be an issue since it's impossible to use another implentation than `DefaultInput` when used through `AnsiConsole.Create(AnsiConsoleSettings settings)`.  

I have also searched for [implementers of IAnsiConsoleInput](https://grep.app/search?q=IAnsiConsoleInput) and I think this change won't break anything since nobody actually implemented `IAnsiConsoleInput`. Only exising implementations which have been udated are being used (at least across a half million public git repos).

The addition of the `CancellationToken` to `IPrompt.Show(IAnsiConsole console, CancellationToken cancellationToken = default)` is also a breaking change but it should be mitigated since it has bee introduced with a default value.
0xced added a commit to 0xced/spectre.console that referenced this pull request Sep 11, 2024
The current prompt APIs suffer from several problems.

First, the prompt APIs are fundamentally synchronous APIs. If we get down to the underlying implementation of all the prompt APIs, i.e. the `DefaultInput` class we can see some issues.

Here's are the problematic implementation (before this commit fixes it):

```csharp
public ConsoleKeyInfo? ReadKey(bool intercept)
{
    return System.Console.ReadKey(intercept);
}

public async Task<ConsoleKeyInfo?> ReadKeyAsync(bool intercept, CancellationToken cancellationToken)
{
    while (true)
    {
        if (cancellationToken.IsCancellationRequested)
        {
            return null;
        }

        if (System.Console.KeyAvailable)
        {
            break;
        }

        await Task.Delay(5, cancellationToken).ConfigureAwait(false);
    }

    return ReadKey(intercept);
}
```

* The syncrhonous `ReadKey` method returns a nullable `ConsoleKeyInfo` struct but `System.Console.ReadKey` can never return a nullable `ConsoleKeyInfo`.
* The asyncrhonous `ReadKeyAsync` method can return `null` only if cancellation has been requested. But this can never actually happen since [Fix deadlock when cancelling prompts (spectreconsole#1439)](spectreconsole#1439) was merged.
* The asyncrhonous `ReadKeyAsync` method is not actually an synchronous method, it's waiting for a key to be pressed in a loop, waiting 5 milliseconds before checking again if it can break out of the loop.

The proposed fix obsoletes the `ReadKeyAsync` method and add cancellation support to the synchronous `ReadKey` method through an optional  `CancellationToken`. It also returns a non-nullable `ConsoleKeyInfo` making it clear that the only way to get out of this method is through cancellation. Then this change bubbles up to all the prompt APIs, also obsoleting the `IPrompt.ShowAsync` methods.

This is a better alternative to [Async overloads for AnsiConsole Prompt/Ask/Confirm (spectreconsole#1194)](spectreconsole#1194) where the actual need is having a `CancellationToken` to perform some cleanup and not having async prompt APIs.

Note that this is a breaking change since it modifies the signatures of the public `IAnsiConsoleInput` interface but that should not be an issue since it's impossible to use another implentation than `DefaultInput` when used through `AnsiConsole.Create(AnsiConsoleSettings settings)`.  

I have also searched for [implementers of IAnsiConsoleInput](https://grep.app/search?q=IAnsiConsoleInput) and I think this change won't break anything since nobody actually implemented `IAnsiConsoleInput`. Only exising implementations which have been udated are being used (at least across a half million public git repos).

The addition of the `CancellationToken` to `IPrompt.Show(IAnsiConsole console, CancellationToken cancellationToken = default)` is also a breaking change but it should be mitigated since it has bee introduced with a default value.
0xced added a commit to 0xced/spectre.console that referenced this pull request Sep 11, 2024
The current prompt APIs suffer from several problems.

First, the prompt APIs are fundamentally synchronous APIs. If we get down to the underlying implementation of all the prompt APIs, i.e. the `DefaultInput` class we can see some issues.

Here's are the problematic implementation (before this commit fixes it):

```csharp
public ConsoleKeyInfo? ReadKey(bool intercept)
{
    return System.Console.ReadKey(intercept);
}

public async Task<ConsoleKeyInfo?> ReadKeyAsync(bool intercept, CancellationToken cancellationToken)
{
    while (true)
    {
        if (cancellationToken.IsCancellationRequested)
        {
            return null;
        }

        if (System.Console.KeyAvailable)
        {
            break;
        }

        await Task.Delay(5, cancellationToken).ConfigureAwait(false);
    }

    return ReadKey(intercept);
}
```

* The syncrhonous `ReadKey` method returns a nullable `ConsoleKeyInfo` struct but `System.Console.ReadKey` can never return a nullable `ConsoleKeyInfo`.
* The asyncrhonous `ReadKeyAsync` method can return `null` only if cancellation has been requested. But this can never actually happen since [Fix deadlock when cancelling prompts (spectreconsole#1439)](spectreconsole#1439) was merged.
* The asyncrhonous `ReadKeyAsync` method is not actually an synchronous method, it's waiting for a key to be pressed in a loop, waiting 5 milliseconds before checking again if it can break out of the loop.

The proposed fix obsoletes the `ReadKeyAsync` method and add cancellation support to the synchronous `ReadKey` method through an optional  `CancellationToken`. It also returns a non-nullable `ConsoleKeyInfo` making it clear that the only way to get out of this method is through cancellation. Then this change bubbles up to all the prompt APIs, also obsoleting the `IPrompt.ShowAsync` methods.

This is a better alternative to [Async overloads for AnsiConsole Prompt/Ask/Confirm (spectreconsole#1194)](spectreconsole#1194) where the actual need is having a `CancellationToken` to perform some cleanup and not having async prompt APIs.

Note that this is a breaking change since it modifies the signatures of the public `IAnsiConsoleInput` interface but that should not be an issue since it's impossible to use another implentation than `DefaultInput` when used through `AnsiConsole.Create(AnsiConsoleSettings settings)`.  

I have also searched for [implementers of IAnsiConsoleInput](https://grep.app/search?q=IAnsiConsoleInput) and I think this change won't break anything since nobody actually implemented `IAnsiConsoleInput`. Only exising implementations which have been udated are being used (at least across a half million public git repos).

The addition of the `CancellationToken` to `IPrompt.Show(IAnsiConsole console, CancellationToken cancellationToken = default)` is also a breaking change but it should be mitigated since it has bee introduced with a default value.
0xced added a commit to 0xced/spectre.console that referenced this pull request Sep 11, 2024
The current prompt APIs suffer from a few problems.

* The syncrhonous `ReadKey` method does not support cancellation.
* The syncrhonous `ReadKey` method returns a nullable `ConsoleKeyInfo` struct but `System.Console.ReadKey` can never return a nullable `ConsoleKeyInfo`.
* The asyncrhonous `ReadKeyAsync` method can return `null` only if cancellation has been requested. But this can never actually happen since [Fix deadlock when cancelling prompts (spectreconsole#1439)](spectreconsole#1439) was merged.

Here's are the problematic implementation (before this commit fixes it):

```csharp
public ConsoleKeyInfo? ReadKey(bool intercept)
{
    return System.Console.ReadKey(intercept);
}

public async Task<ConsoleKeyInfo?> ReadKeyAsync(bool intercept, CancellationToken cancellationToken)
{
    while (true)
    {
        if (cancellationToken.IsCancellationRequested)
        {
            return null;
        }

        if (System.Console.KeyAvailable)
        {
            break;
        }

        await Task.Delay(5, cancellationToken).ConfigureAwait(false);
    }

    return ReadKey(intercept);
}
```

Note that adding a `CancellationToken` parameter and returning `ConsoleKeyInfo` instead of `ConsoleKeyInfo?` is a breaking change since it modifies the signatures of the public `IAnsiConsoleInput` interface. But this should not be an issue since it's impossible to use another implentation than `DefaultInput` when used through `AnsiConsole.Create(AnsiConsoleSettings settings)`.  

I have also searched for [implementers of IAnsiConsoleInput](https://grep.app/search?q=IAnsiConsoleInput) and I think this change won't break anything since nobody actually implemented `IAnsiConsoleInput`. Only exising implementations which have been udated are being used (at least across a half million public git repos).

The addition of the `CancellationToken` to `IPrompt.Show(IAnsiConsole console, CancellationToken cancellationToken = default)` is also a breaking change but it should be mitigated since it has bee introduced with a default value.
0xced added a commit to 0xced/spectre.console that referenced this pull request Sep 19, 2024
The current prompt APIs suffer from a few problems.

* The syncrhonous `ReadKey` method does not support cancellation.
* The syncrhonous `ReadKey` method returns a nullable `ConsoleKeyInfo` struct but `System.Console.ReadKey` can never return a nullable `ConsoleKeyInfo`.
* The asyncrhonous `ReadKeyAsync` method can return `null` only if cancellation has been requested. But this can never actually happen since [Fix deadlock when cancelling prompts (spectreconsole#1439)](spectreconsole#1439) was merged.

Here's are the problematic implementation (before this commit fixes it):

```csharp
public ConsoleKeyInfo? ReadKey(bool intercept)
{
    return System.Console.ReadKey(intercept);
}

public async Task<ConsoleKeyInfo?> ReadKeyAsync(bool intercept, CancellationToken cancellationToken)
{
    while (true)
    {
        if (cancellationToken.IsCancellationRequested)
        {
            return null;
        }

        if (System.Console.KeyAvailable)
        {
            break;
        }

        await Task.Delay(5, cancellationToken).ConfigureAwait(false);
    }

    return ReadKey(intercept);
}
```

Note that adding a `CancellationToken` parameter and returning `ConsoleKeyInfo` instead of `ConsoleKeyInfo?` is a breaking change since it modifies the signatures of the public `IAnsiConsoleInput` interface. But this should not be an issue since it's impossible to use another implentation than `DefaultInput` when used through `AnsiConsole.Create(AnsiConsoleSettings settings)`.  

I have also searched for [implementers of IAnsiConsoleInput](https://grep.app/search?q=IAnsiConsoleInput) and I think this change won't break anything since nobody actually implemented `IAnsiConsoleInput`. Only exising implementations which have been udated are being used (at least across a half million public git repos).

The addition of the `CancellationToken` to `IPrompt.Show(IAnsiConsole console, CancellationToken cancellationToken = default)` is also a breaking change but it should be mitigated since it has bee introduced with a default value.
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.

Prompt Cancellation is broken
2 participants