Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

Description

Task<TResult>'s debug proxy was showing default(TResult) for the Result property of faulted/cancelled tasks, misleading developers about actual behavior. The debugger should show that accessing Result will throw.

Changes

  • Rename SystemThreadingTasks_FutureDebugView<TResult>SystemThreadingTasks_TaskOfTResultDebugView<TResult> ("Future" was an old name for "Task")
  • Change Result property to delegate directly to m_task.Result instead of returning default for non-success states

Before: public TResult? Result => m_task.Status == TaskStatus.RanToCompletion ? m_task.Result : default;

After: public TResult Result => m_task.Result;

Now the debugger properly reflects the exception that would be thrown when accessing Result on a faulted task.

Original prompt

This section details on the original issue you should resolve

<issue_title>Task<T> debug proxy is misleading about Result of a non-success task</issue_title>
<issue_description>### Description

System.Threading.Task<T> has a custom debug proxy. This debug proxy returns default value of T instead of indicating a potential exception for a Result property of a faulted task

Reproduction Steps

var mt = M();
await ((Task)mt).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);

Console.WriteLine(mt.Result);

async Task<string> M()
{
    throw new NotImplementedException();
}
  • Break point on Console... line.
  • Start debugging
  • Reach the break point and inspect Result property

Expected behavior

Debug proxy indicates that accessing Result will throw an exception

Actual behavior

Result shows default value (in this case null), misleading developers about actual property behavior:

Image

Regression?

No

Known Workarounds

No response

Configuration

No response

Other information

No response</issue_description>

<agent_instructions>Change SystemThreadingTasks_FutureDebugView's Result to just delegate to the task's Result. Also rename that type; "Future" was an old name for "Task", so this should be more like "TaskTResultDebugView" or something similar. (If there are other references to "Future" where it should be "Task", please address those, too.)</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@stephentoub > Debug proxy indicates that accessing Result will throw an exception > It shows that the task is in a Faulted state and that there's an exception. Wait, Result, etc will all throw in that state.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…askOfTResultDebugView and delegate Result to task.Result

Co-authored-by: stephentoub <[email protected]>
Copilot AI changed the title [WIP] Fix misleading debug proxy for Task<T> Result property Fix Task&lt;TResult&gt; debug proxy Result behavior and rename from Future Jan 29, 2026
Copilot AI requested a review from stephentoub January 29, 2026 13:30
@stephentoub stephentoub marked this pull request as ready for review January 29, 2026 13:31
Copilot AI review requested due to automatic review settings January 29, 2026 13:31
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-threading-tasks
See info in area-owners.md if you want to be subscribed.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task<T> debug proxy is misleading about Result of a non-success task

3 participants