Disable debugger evaluation of ValueTask<T>.Result (dotnet/coreclr#25727)
commitef3cbe9c56a4c0bdbb9eb675c1771e388481d160
authorStephen Toub <stoub@microsoft.com>
Tue, 16 Jul 2019 19:28:53 +0000 (16 15:28 -0400)
committerMarek Safar <marek.safar@gmail.com>
Wed, 24 Jul 2019 07:45:03 +0000 (24 09:45 +0200)
tree9e9aefe03eba37ac287cdaace4e1e15315e0ce56
parent927d8c322dbef647b02053549f2cf09c77727046
Disable debugger evaluation of ValueTask<T>.Result (dotnet/coreclr#25727)

If the debugger evaluates a `ValueTask<T>`'s `Result`, that counts as the "you should only consume a `ValueTask<T>`" once, and ends up breaking / hanging / throwing exceptions and other bad stuff while stepping through code in the debugger.

This commit addresses that in two ways:
1. Adds `[DebuggerBrowsable(Never)]` to `Result` to prevent it from showing up in debugger views.
2. Adds a NotifyOfCrossThreadDependency call to its ToString.  This prevents the debugger from using ToString to show an implicit representation of the instance, and it forces the developer explicitly trying to access ToString (e.g. in the watch window) to click a button acknowleding the impact.

(Post 3.0, we should consider removing the `ValueTask<T>.ToString()` override altogether.)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
netcore/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs