diff --git a/src/Grpc.AspNetCore.Server/Internal/PipeExtensions.cs b/src/Grpc.AspNetCore.Server/Internal/PipeExtensions.cs index ccd902c91..800ee2922 100644 --- a/src/Grpc.AspNetCore.Server/Internal/PipeExtensions.cs +++ b/src/Grpc.AspNetCore.Server/Internal/PipeExtensions.cs @@ -21,6 +21,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO.Pipelines; +using System.Runtime.CompilerServices; using Grpc.Core; using Grpc.Net.Compression; using Microsoft.Extensions.Logging; @@ -280,6 +281,9 @@ public static async ValueTask ReadSingleMessageAsync(this PipeReader input /// Message deserializer. /// The cancellation token. /// Complete message data or null if the stream is complete. +#if NET6_0_OR_GREATER + [AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))] +#endif public static async ValueTask ReadStreamMessageAsync(this PipeReader input, HttpContextServerCallContext serverCallContext, Func deserializer, CancellationToken cancellationToken = default) where T : class {