From 77ae8af69c6368bacb40b5b110d6a36807611d67 Mon Sep 17 00:00:00 2001 From: Mayuki Sawatari Date: Thu, 18 Aug 2022 14:41:05 +0900 Subject: [PATCH] Use PoolingAsyncValueTaskMethodBuilder on ReadStreamMessageAsync method (#1850) Co-authored-by: James Newton-King --- src/Grpc.AspNetCore.Server/Internal/PipeExtensions.cs | 4 ++++ 1 file changed, 4 insertions(+) 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 {