Skip to content

GH2153: Fix async stack traces rendering as MoveNext() instead of source methods - #2154

Merged
patriksvensson merged 1 commit into
spectreconsole:mainfrom
devlead:feature/gh-2153
Jun 18, 2026
Merged

patriksvensson merged 1 commit into
spectreconsole:mainfrom
devlead:feature/gh-2153

Conversation

@devlead

@devlead devlead commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
  • I have read the Contribution Guidelines
  • I have checked that there isn't already another pull request that solves the above issue
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors

Changes

Async exception stack frames were showing async void MoveNext() because TryResolveStateMachineMethod took MethodBase by value. The resolved method (e.g. ExecuteAsync) was assigned to a local copy and never propagated back to the caller, matching .NET StackTrace behavior only partially.

Example

catch(Exception exception)
{
    AnsiConsole.WriteException(
        exception,
        ExceptionFormats.ShortenEverything | ExceptionFormats.ShowLinks
    );
}

Before fix (broken — MethodBase passed by value)

InvalidOperationException: Throwing async!
  at async void MoveNext() in Exceptions.cs:100
  at void ThrowFromAsync() in Exceptions.cs:200
  at Exception GetException(Action action) in ExceptionTests.cs:300

After fix (ref MethodBase — matches .NET StackTrace)

InvalidOperationException: Throwing async!
  at async Task MethodThatThrowsAsync() in Exceptions.cs:100
  at void ThrowFromAsync() in Exceptions.cs:200
  at Exception GetException(Action action) in ExceptionTests.cs:300

Please upvote 👍 this pull request if you are interested in it.

…) instead of source methods

Async exception stack frames were showing `async void MoveNext()` because
`TryResolveStateMachineMethod` took `MethodBase` by value. The resolved
method (e.g. `ExecuteAsync`) was assigned to a local copy and never
propagated back to the caller, matching .NET StackTrace behavior only
partially.

- Pass `MethodBase` by ref in `TryResolveStateMachineMethod` and at its call site in `GetMethodName`
- Add async throw helpers to `TestExceptions` for regression coverage
- Add verifier test and snapshot asserting resolved async method names
- Fixes spectreconsole#2153
@patriksvensson
patriksvensson merged commit a0913f8 into spectreconsole:main Jun 18, 2026
3 checks passed
@patriksvensson

Copy link
Copy Markdown
Contributor

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

This was referenced Jun 24, 2026
rdeveen added a commit to rdeveen/azure-security-analyzer-cli that referenced this pull request Sep 6, 2026
Updated
[Spectre.Console](https://github.com/spectreconsole/spectre.console)
from 0.55.2 to 0.57.2.

<details>
<summary>Release notes</summary>

_Sourced from [Spectre.Console's
releases](https://github.com/spectreconsole/spectre.console/releases)._

## 0.57.2

## What's Change

* Allow wrapping of status text by @​patriksvensson in
spectreconsole/spectre.console#2158

**Full Changelog**:
spectreconsole/spectre.console@0.57.1...0.57.2

## 0.57.1

## What's Changed

* GH2153: Fix async stack traces rendering as MoveNext() instead of
source methods by [@​devlead](https://github.com/devlead) in
[#​2154](spectreconsole/spectre.console#2154)

**Full Changelog**:
spectreconsole/spectre.console@0.57.0...0.57.1

## 0.57.0

## What's Changed
* Make source generator output deterministic (LF, no BOM) by
[@​phil-scott-78](https://github.com/phil-scott-78) in
[#​2143](spectreconsole/spectre.console#2143)
* Add new box border styles including beveled, dashed, dotted, heavy,
and rounded variants by
[@​phil-scott-78](https://github.com/phil-scott-78) in
[#​2142](spectreconsole/spectre.console#2142)
* Should preserve auto links when wrapped in grid by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2149](spectreconsole/spectre.console#2149)

**Full Changelog**:
spectreconsole/spectre.console@0.56.0...0.57.0

## 0.56.0

## What's Changed

* Ensure redirected output works as expected by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2098](spectreconsole/spectre.console#2098)
* Add missing text prompt suffix by
[@​merklegroot](https://github.com/merklegroot) in
[#​2102](spectreconsole/spectre.console#2102)
* Fix Align measure to respect explicitly set width by
[@​GrantTotinov](https://github.com/GrantTotinov) in
[#​2101](spectreconsole/spectre.console#2101)
* Option to exclude vertical padding for live progress renderer by
[@​james-newell-forge](https://github.com/james-newell-forge) in
[#​2100](spectreconsole/spectre.console#2100)
* Don't emit ANSI sequence for 0 movement by
[@​merklegroot](https://github.com/merklegroot) in
[#​2104](spectreconsole/spectre.console#2104)
* ConfirmationPrompt: Allow submission without Enter key by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2111](spectreconsole/spectre.console#2111)
* Add two new layout modes for FigletText by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2066](spectreconsole/spectre.console#2066)
* Fix escaping of interpolated arguments in markup by
[@​GrantTotinov](https://github.com/GrantTotinov) in
[#​2118](spectreconsole/spectre.console#2118)
* Allow validation chaining by
[@​AntekOlszewski](https://github.com/AntekOlszewski) in
[#​2116](spectreconsole/spectre.console#2116)
* Fix grid regression where expansion did not work by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2127](spectreconsole/spectre.console#2127)
* Preserve links in segments by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2135](spectreconsole/spectre.console#2135)

## New Contributors

* [@​merklegroot](https://github.com/merklegroot) made their first
contribution in
[#​2102](spectreconsole/spectre.console#2102)
* [@​GrantTotinov](https://github.com/GrantTotinov) made their first
contribution in
[#​2101](spectreconsole/spectre.console#2101)
* [@​james-newell-forge](https://github.com/james-newell-forge) made
their first contribution in
[#​2100](spectreconsole/spectre.console#2100)

**Full Changelog**:
spectreconsole/spectre.console@0.55.2...0.56.0

Commits viewable in [compare
view](spectreconsole/spectre.console@0.55.2...0.57.2).
</details>

Updated
[Spectre.Console.Json](https://github.com/spectreconsole/spectre.console)
from 0.55.2 to 0.57.2.

<details>
<summary>Release notes</summary>

_Sourced from [Spectre.Console.Json's
releases](https://github.com/spectreconsole/spectre.console/releases)._

## 0.57.2

## What's Change

* Allow wrapping of status text by @​patriksvensson in
spectreconsole/spectre.console#2158

**Full Changelog**:
spectreconsole/spectre.console@0.57.1...0.57.2

## 0.57.1

## What's Changed

* GH2153: Fix async stack traces rendering as MoveNext() instead of
source methods by [@​devlead](https://github.com/devlead) in
[#​2154](spectreconsole/spectre.console#2154)

**Full Changelog**:
spectreconsole/spectre.console@0.57.0...0.57.1

## 0.57.0

## What's Changed
* Make source generator output deterministic (LF, no BOM) by
[@​phil-scott-78](https://github.com/phil-scott-78) in
[#​2143](spectreconsole/spectre.console#2143)
* Add new box border styles including beveled, dashed, dotted, heavy,
and rounded variants by
[@​phil-scott-78](https://github.com/phil-scott-78) in
[#​2142](spectreconsole/spectre.console#2142)
* Should preserve auto links when wrapped in grid by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2149](spectreconsole/spectre.console#2149)

**Full Changelog**:
spectreconsole/spectre.console@0.56.0...0.57.0

## 0.56.0

## What's Changed

* Ensure redirected output works as expected by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2098](spectreconsole/spectre.console#2098)
* Add missing text prompt suffix by
[@​merklegroot](https://github.com/merklegroot) in
[#​2102](spectreconsole/spectre.console#2102)
* Fix Align measure to respect explicitly set width by
[@​GrantTotinov](https://github.com/GrantTotinov) in
[#​2101](spectreconsole/spectre.console#2101)
* Option to exclude vertical padding for live progress renderer by
[@​james-newell-forge](https://github.com/james-newell-forge) in
[#​2100](spectreconsole/spectre.console#2100)
* Don't emit ANSI sequence for 0 movement by
[@​merklegroot](https://github.com/merklegroot) in
[#​2104](spectreconsole/spectre.console#2104)
* ConfirmationPrompt: Allow submission without Enter key by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2111](spectreconsole/spectre.console#2111)
* Add two new layout modes for FigletText by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2066](spectreconsole/spectre.console#2066)
* Fix escaping of interpolated arguments in markup by
[@​GrantTotinov](https://github.com/GrantTotinov) in
[#​2118](spectreconsole/spectre.console#2118)
* Allow validation chaining by
[@​AntekOlszewski](https://github.com/AntekOlszewski) in
[#​2116](spectreconsole/spectre.console#2116)
* Fix grid regression where expansion did not work by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2127](spectreconsole/spectre.console#2127)
* Preserve links in segments by
[@​patriksvensson](https://github.com/patriksvensson) in
[#​2135](spectreconsole/spectre.console#2135)

## New Contributors

* [@​merklegroot](https://github.com/merklegroot) made their first
contribution in
[#​2102](spectreconsole/spectre.console#2102)
* [@​GrantTotinov](https://github.com/GrantTotinov) made their first
contribution in
[#​2101](spectreconsole/spectre.console#2101)
* [@​james-newell-forge](https://github.com/james-newell-forge) made
their first contribution in
[#​2100](spectreconsole/spectre.console#2100)

**Full Changelog**:
spectreconsole/spectre.console@0.55.2...0.56.0

Commits viewable in [compare
view](spectreconsole/spectre.console@0.55.2...0.57.2).
</details>

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)

</details>
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.

ExceptionRenderableBuilder shows async state machine methods (i.e. MoveNext)

2 participants