Table of Contents

GR0066: Consider ValueTask instead of Task

TitleConsider ValueTask<T> instead of Task<T>
IdGR0066
CategoryPerformance
Default SeverityInfo
Enabled By DefaultTrue
DescriptionWhen a method frequently completes synchronously (e.g. via Task.FromResult or a fast-path branch), returning ValueTask<T> avoids a heap allocation. This is a performance suggestion only; ValueTask<T> has stricter consumption rules and is not universally better than Task<T>.
Custom Tags