Skip to content

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

@DoctorKrolic

Description

@DoctorKrolic

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions