Description
I haven't fully investigated all of these, just enough to see that there might be an issue to be followed up on...
- Ignored results:
These are calling a ValueTask-returning method and ignoring the result. If the ValueTask is backed by something that's pooled, not awaiting it could result in that pooled object getting thrown away.
- Semi-ignored result, and potential reuse:
This is storing a ValueTask into a field, which is then returned from every call to WriteStreamSuffixAsync:
Same for HTTP/1.1:
That in turn is used in WriteSuffix:
Two potential issues with that: a) if it's already completed successfully we never call GetAwaiter().GetResult() on it which means if it's pooled it won't be returned, and b) if it wasn't completed and we await it, then if it's used again we're going to be reusing an already consumed instance.
- Attempting to synchronously block on a ValueTask
a) Synchronous blocking in ASP.NET?
b) Such use isn't supported on ValueTasks. It may happen to work today based on how the ValueTask was created, but it's in no way guaranteed to.
This one is similar. The comment talks about using Result being ok because it calls GetAwaiter().GetResult(), but GetAwaiter().GetResult() isn't guaranteed to block. It'll work ok if the implementation is backed by a value or a Task, but if it's backed by an IValueTaskSource, all bets are off.
cc: @davidfowl