diff --git a/perf/benchmarkapps/GrpcAspNetCoreServer/Program.cs b/perf/benchmarkapps/GrpcAspNetCoreServer/Program.cs index 9fd395c26..f729a660f 100644 --- a/perf/benchmarkapps/GrpcAspNetCoreServer/Program.cs +++ b/perf/benchmarkapps/GrpcAspNetCoreServer/Program.cs @@ -120,13 +120,8 @@ public static IHostBuilder CreateHostBuilder(string[] args) { Console.WriteLine($"Console Logging enabled with level '{logLevel}'"); - loggerFactory -#if NET5_0_OR_GREATER - .AddSimpleConsole(o => o.TimestampFormat = "ss.ffff ") -#else - .AddConsole(o => o.TimestampFormat = "ss.ffff ") -#endif - .SetMinimumLevel(logLevel); + loggerFactory.AddSimpleConsole(o => o.TimestampFormat = "ss.ffff ") + .SetMinimumLevel(logLevel); } }) .UseDefaultServiceProvider((context, options) => @@ -163,7 +158,6 @@ private static void ConfigureListenOptions(ListenOptions listenOptions, IConfigu } }); } -#if NET6_0_OR_GREATER else if (protocol.Equals("h3", StringComparison.OrdinalIgnoreCase)) { listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; @@ -177,7 +171,6 @@ private static void ConfigureListenOptions(ListenOptions listenOptions, IConfigu } }); } -#endif else if (protocol.Equals("h2c", StringComparison.OrdinalIgnoreCase)) { listenOptions.Protocols = HttpProtocols.Http2; diff --git a/perf/benchmarkapps/GrpcAspNetCoreServer/Startup.cs b/perf/benchmarkapps/GrpcAspNetCoreServer/Startup.cs index bf590136e..cb9ba210a 100644 --- a/perf/benchmarkapps/GrpcAspNetCoreServer/Startup.cs +++ b/perf/benchmarkapps/GrpcAspNetCoreServer/Startup.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -21,9 +21,7 @@ using Grpc.Shared; using Grpc.Testing; using Grpc.Tests.Shared; -#if NET5_0_OR_GREATER using Microsoft.AspNetCore.Authentication.Certificate; -#endif using Newtonsoft.Json; namespace GrpcAspNetCoreServer; @@ -41,10 +39,8 @@ public void ConfigureServices(IServiceCollection services) { services.AddGrpc(o => { -#if NET5_0_OR_GREATER // Small performance benefit to not add catch-all routes to handle UNIMPLEMENTED for unknown services o.IgnoreUnknownServices = true; -#endif }); services.Configure(c => { @@ -54,7 +50,6 @@ public void ConfigureServices(IServiceCollection services) services.AddSingleton(); services.AddControllers(); -#if NET5_0_OR_GREATER bool.TryParse(_config["enableCertAuth"], out var enableCertAuth); if (enableCertAuth) { @@ -67,7 +62,6 @@ public void ConfigureServices(IServiceCollection services) options.AllowedCertificateTypes = CertificateTypes.All; }); } -#endif } public void Configure(IApplicationBuilder app, IHostApplicationLifetime applicationLifetime) @@ -83,14 +77,12 @@ public void Configure(IApplicationBuilder app, IHostApplicationLifetime applicat app.UseRouting(); -#if NET5_0_OR_GREATER bool.TryParse(_config["enableCertAuth"], out var enableCertAuth); if (enableCertAuth) { app.UseAuthentication(); app.UseAuthorization(); } -#endif #if GRPC_WEB bool.TryParse(_config["enableGrpcWeb"], out var enableGrpcWeb); @@ -139,12 +131,10 @@ public void Configure(IApplicationBuilder app, IHostApplicationLifetime applicat private void ConfigureAuthorization(IEndpointConventionBuilder builder) { -#if NET5_0_OR_GREATER bool.TryParse(_config["enableCertAuth"], out var enableCertAuth); if (enableCertAuth) { builder.RequireAuthorization(); } -#endif } } diff --git a/perf/benchmarkapps/GrpcClient/ClientOptions.cs b/perf/benchmarkapps/GrpcClient/ClientOptions.cs index 425338661..44ed9f882 100644 --- a/perf/benchmarkapps/GrpcClient/ClientOptions.cs +++ b/perf/benchmarkapps/GrpcClient/ClientOptions.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -23,10 +23,8 @@ namespace GrpcClient; public class ClientOptions { public Uri? Url { get; set; } -#if NET5_0_OR_GREATER public string? UdsFileName { get; set; } public string? NamedPipeName { get; set; } -#endif public int Connections { get; set; } public int Warmup { get; set; } public int Duration { get; set; } @@ -41,4 +39,4 @@ public class ClientOptions public GrpcClientType GrpcClientType { get; set; } public int Streams { get; set; } public int Deadline { get; set; } -} \ No newline at end of file +} diff --git a/perf/benchmarkapps/GrpcClient/NamedPipeConnectionFactory.cs b/perf/benchmarkapps/GrpcClient/NamedPipeConnectionFactory.cs index ea261cf39..0839ea507 100644 --- a/perf/benchmarkapps/GrpcClient/NamedPipeConnectionFactory.cs +++ b/perf/benchmarkapps/GrpcClient/NamedPipeConnectionFactory.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -19,8 +19,6 @@ using System.IO.Pipes; using System.Security.Principal; -#if NET5_0_OR_GREATER - namespace GrpcClient; public class NamedPipeConnectionFactory @@ -56,5 +54,3 @@ public async ValueTask ConnectAsync(SocketsHttpConnectionContext _, } } } - -#endif diff --git a/perf/benchmarkapps/GrpcClient/Program.cs b/perf/benchmarkapps/GrpcClient/Program.cs index 88275c5f9..7e86b3a4b 100644 --- a/perf/benchmarkapps/GrpcClient/Program.cs +++ b/perf/benchmarkapps/GrpcClient/Program.cs @@ -465,10 +465,6 @@ private static ChannelBase CreateChannel(string target) var address = useTls ? "https://" : "http://"; address += target; -#if NETCOREAPP3_1 - AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); -#endif - var httpClientHandler = new SocketsHttpHandler(); httpClientHandler.UseProxy = false; httpClientHandler.AllowAutoRedirect = false; @@ -479,7 +475,7 @@ private static ChannelBase CreateChannel(string target) var clientCertificates = X509CertificateLoader.LoadPkcs12CollectionFromFile(certPath, "1111"); httpClientHandler.SslOptions.ClientCertificates = clientCertificates; } -#if NET5_0_OR_GREATER + if (!string.IsNullOrEmpty(_options.UdsFileName)) { var connectionFactory = new UnixDomainSocketConnectionFactory(new UnixDomainSocketEndPoint(ResolveUdsPath(_options.UdsFileName))); @@ -490,7 +486,6 @@ private static ChannelBase CreateChannel(string target) var connectionFactory = new NamedPipeConnectionFactory(_options.NamedPipeName); httpClientHandler.ConnectCallback = connectionFactory.ConnectAsync; } -#endif httpClientHandler.SslOptions.RemoteCertificateValidationCallback = (object sender, X509Certificate? certificate, X509Chain? chain, SslPolicyErrors sslPolicyErrors) => true; @@ -509,11 +504,7 @@ private static ChannelBase CreateChannel(string target) return GrpcChannel.ForAddress(address, new GrpcChannelOptions { -#if NET5_0_OR_GREATER HttpHandler = httpMessageHandler, -#else - HttpClient = new HttpClient(httpMessageHandler), -#endif LoggerFactory = _loggerFactory, HttpVersion = versionOverride }); diff --git a/perf/benchmarkapps/GrpcClient/UnixDomainSocketConnectionFactory.cs b/perf/benchmarkapps/GrpcClient/UnixDomainSocketConnectionFactory.cs index 3d1548336..e4e39b2b1 100644 --- a/perf/benchmarkapps/GrpcClient/UnixDomainSocketConnectionFactory.cs +++ b/perf/benchmarkapps/GrpcClient/UnixDomainSocketConnectionFactory.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -19,8 +19,6 @@ using System.Net; using System.Net.Sockets; -#if NET5_0_OR_GREATER - namespace GrpcClient; public class UnixDomainSocketConnectionFactory @@ -48,5 +46,3 @@ public async ValueTask ConnectAsync(SocketsHttpConnectionContext _, Canc } } } - -#endif diff --git a/src/Grpc.AspNetCore.Server/GrpcEndpointRouteBuilderExtensions.cs b/src/Grpc.AspNetCore.Server/GrpcEndpointRouteBuilderExtensions.cs index 93f4993be..f583a2c4c 100644 --- a/src/Grpc.AspNetCore.Server/GrpcEndpointRouteBuilderExtensions.cs +++ b/src/Grpc.AspNetCore.Server/GrpcEndpointRouteBuilderExtensions.cs @@ -36,11 +36,7 @@ public static class GrpcEndpointRouteBuilderExtensions /// The service type to map requests to. /// The to add the route to. /// A for endpoints associated with the service. - public static GrpcServiceEndpointConventionBuilder MapGrpcService< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService>(this IEndpointRouteBuilder builder) where TService : class + public static GrpcServiceEndpointConventionBuilder MapGrpcService<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService>(this IEndpointRouteBuilder builder) where TService : class { ArgumentNullThrowHelper.ThrowIfNull(builder); diff --git a/src/Grpc.AspNetCore.Server/GrpcMethodMetadata.cs b/src/Grpc.AspNetCore.Server/GrpcMethodMetadata.cs index cd3577376..d37d9e6a2 100644 --- a/src/Grpc.AspNetCore.Server/GrpcMethodMetadata.cs +++ b/src/Grpc.AspNetCore.Server/GrpcMethodMetadata.cs @@ -33,12 +33,7 @@ public sealed class GrpcMethodMetadata /// /// The implementing service type. /// The method representation. - public GrpcMethodMetadata( -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - Type serviceType, - IMethod method) + public GrpcMethodMetadata([DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] Type serviceType, IMethod method) { ArgumentNullThrowHelper.ThrowIfNull(serviceType); ArgumentNullThrowHelper.ThrowIfNull(method); @@ -50,9 +45,7 @@ public GrpcMethodMetadata( /// /// Gets the implementing service type. /// -#if NET5_0_OR_GREATER [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif public Type ServiceType { get; } /// diff --git a/src/Grpc.AspNetCore.Server/IGrpcServiceActivator.cs b/src/Grpc.AspNetCore.Server/IGrpcServiceActivator.cs index 7a99052f4..b36e9fc22 100644 --- a/src/Grpc.AspNetCore.Server/IGrpcServiceActivator.cs +++ b/src/Grpc.AspNetCore.Server/IGrpcServiceActivator.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -25,11 +25,7 @@ namespace Grpc.AspNetCore.Server; /// A activator abstraction. /// /// The service type. -public interface IGrpcServiceActivator< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TGrpcService> where TGrpcService : class +public interface IGrpcServiceActivator<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TGrpcService> where TGrpcService : class { /// /// Creates a service. diff --git a/src/Grpc.AspNetCore.Server/InterceptorCollection.cs b/src/Grpc.AspNetCore.Server/InterceptorCollection.cs index c8e93e216..fec8bc61a 100644 --- a/src/Grpc.AspNetCore.Server/InterceptorCollection.cs +++ b/src/Grpc.AspNetCore.Server/InterceptorCollection.cs @@ -33,11 +33,7 @@ public class InterceptorCollection : Collection /// /// The interceptor type. /// The list of arguments to pass to the interceptor constructor when creating an instance. - public void Add< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(InterceptorRegistration.InterceptorAccessibility)] -#endif - TInterceptor>(params object[] args) where TInterceptor : Interceptor + public void Add<[DynamicallyAccessedMembers(InterceptorRegistration.InterceptorAccessibility)] TInterceptor>(params object[] args) where TInterceptor : Interceptor { Add(typeof(TInterceptor), args); } @@ -47,11 +43,7 @@ public void Add< /// /// The interceptor type. /// The list of arguments to pass to the interceptor constructor when creating an instance. - public void Add( -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(InterceptorRegistration.InterceptorAccessibility)] -#endif - Type interceptorType, params object[] args) + public void Add([DynamicallyAccessedMembers(InterceptorRegistration.InterceptorAccessibility)] Type interceptorType, params object[] args) { ArgumentNullThrowHelper.ThrowIfNull(interceptorType); diff --git a/src/Grpc.AspNetCore.Server/InterceptorRegistration.cs b/src/Grpc.AspNetCore.Server/InterceptorRegistration.cs index 2e6d23412..b57f378b3 100644 --- a/src/Grpc.AspNetCore.Server/InterceptorRegistration.cs +++ b/src/Grpc.AspNetCore.Server/InterceptorRegistration.cs @@ -28,17 +28,11 @@ namespace Grpc.AspNetCore.Server; /// public class InterceptorRegistration { -#if NET5_0_OR_GREATER internal const DynamicallyAccessedMemberTypes InterceptorAccessibility = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods; -#endif internal object[] _args; - internal InterceptorRegistration( -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(InterceptorAccessibility)] -#endif - Type type, object[] arguments) + internal InterceptorRegistration([DynamicallyAccessedMembers(InterceptorAccessibility)]Type type, object[] arguments) { ArgumentNullThrowHelper.ThrowIfNull(type); ArgumentNullThrowHelper.ThrowIfNull(arguments); @@ -58,9 +52,7 @@ internal InterceptorRegistration( /// /// Get the type of the interceptor. /// -#if NET5_0_OR_GREATER [DynamicallyAccessedMembers(InterceptorAccessibility)] -#endif public Type Type { get; } /// @@ -71,12 +63,10 @@ internal InterceptorRegistration( private IGrpcInterceptorActivator? _interceptorActivator; private ObjectFactory? _factory; -#if NET5_0_OR_GREATER [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Type parameter members are preserved with DynamicallyAccessedMembers on InterceptorRegistration.Type property.")] [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", Justification = "Type definition is explicitly specified and type argument is always an Interceptor type.")] -#endif internal IGrpcInterceptorActivator GetActivator(IServiceProvider serviceProvider) { // Not thread safe. Side effect is resolving the service twice. diff --git a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ClientStreamingServerCallHandler.cs b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ClientStreamingServerCallHandler.cs index 61655c71a..f6d9bb155 100644 --- a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ClientStreamingServerCallHandler.cs +++ b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ClientStreamingServerCallHandler.cs @@ -24,11 +24,7 @@ namespace Grpc.AspNetCore.Server.Internal.CallHandlers; -internal class ClientStreamingServerCallHandler< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService, TRequest, TResponse> : ServerCallHandlerBase +internal class ClientStreamingServerCallHandler<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerCallHandlerBase where TRequest : class where TResponse : class where TService : class diff --git a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/DuplexStreamingServerCallHandler.cs b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/DuplexStreamingServerCallHandler.cs index 9513ab1b6..cc5318511 100644 --- a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/DuplexStreamingServerCallHandler.cs +++ b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/DuplexStreamingServerCallHandler.cs @@ -23,11 +23,7 @@ namespace Grpc.AspNetCore.Server.Internal.CallHandlers; -internal class DuplexStreamingServerCallHandler< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService, TRequest, TResponse> : ServerCallHandlerBase +internal class DuplexStreamingServerCallHandler<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerCallHandlerBase where TRequest : class where TResponse : class where TService : class diff --git a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerCallHandlerBase.cs b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerCallHandlerBase.cs index 3596d3131..f4db8601f 100644 --- a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerCallHandlerBase.cs +++ b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerCallHandlerBase.cs @@ -30,11 +30,7 @@ namespace Grpc.AspNetCore.Server.Internal.CallHandlers; -internal abstract class ServerCallHandlerBase< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService, TRequest, TResponse> +internal abstract class ServerCallHandlerBase<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> where TService : class where TRequest : class where TResponse : class @@ -60,10 +56,7 @@ public Task HandleCallAsync(HttpContext httpContext) } if (!GrpcProtocolConstants.IsHttp2(httpContext.Request.Protocol) -#if NET6_0_OR_GREATER - && !GrpcProtocolConstants.IsHttp3(httpContext.Request.Protocol) -#endif - ) + && !GrpcProtocolConstants.IsHttp3(httpContext.Request.Protocol)) { return ProcessNonHttp2Request(httpContext); } diff --git a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerStreamingServerCallHandler.cs b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerStreamingServerCallHandler.cs index e29c58be5..404822f98 100644 --- a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerStreamingServerCallHandler.cs +++ b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerStreamingServerCallHandler.cs @@ -23,11 +23,7 @@ namespace Grpc.AspNetCore.Server.Internal.CallHandlers; -internal class ServerStreamingServerCallHandler< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService, TRequest, TResponse> : ServerCallHandlerBase +internal class ServerStreamingServerCallHandler<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerCallHandlerBase where TRequest : class where TResponse : class where TService : class diff --git a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/UnaryServerCallHandler.cs b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/UnaryServerCallHandler.cs index d959f9dc2..499dc6491 100644 --- a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/UnaryServerCallHandler.cs +++ b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/UnaryServerCallHandler.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -24,11 +24,7 @@ namespace Grpc.AspNetCore.Server.Internal.CallHandlers; -internal class UnaryServerCallHandler< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService, TRequest, TResponse> : ServerCallHandlerBase +internal class UnaryServerCallHandler<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerCallHandlerBase where TRequest : class where TResponse : class where TService : class diff --git a/src/Grpc.AspNetCore.Server/Internal/DefaultGrpcServiceActivator.cs b/src/Grpc.AspNetCore.Server/Internal/DefaultGrpcServiceActivator.cs index 2bba1f8bb..e911697c8 100644 --- a/src/Grpc.AspNetCore.Server/Internal/DefaultGrpcServiceActivator.cs +++ b/src/Grpc.AspNetCore.Server/Internal/DefaultGrpcServiceActivator.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -21,11 +21,7 @@ namespace Grpc.AspNetCore.Server.Internal; -internal sealed class DefaultGrpcServiceActivator< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TGrpcService> : IGrpcServiceActivator where TGrpcService : class +internal sealed class DefaultGrpcServiceActivator<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TGrpcService> : IGrpcServiceActivator where TGrpcService : class { private static readonly Lazy _objectFactory = new Lazy(static () => ActivatorUtilities.CreateFactory(typeof(TGrpcService), Type.EmptyTypes)); diff --git a/src/Grpc.AspNetCore.Server/Internal/GrpcProtocolConstants.cs b/src/Grpc.AspNetCore.Server/Internal/GrpcProtocolConstants.cs index b9fe5afaa..269cf9a4c 100644 --- a/src/Grpc.AspNetCore.Server/Internal/GrpcProtocolConstants.cs +++ b/src/Grpc.AspNetCore.Server/Internal/GrpcProtocolConstants.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -28,51 +28,16 @@ internal static class GrpcProtocolConstants internal const string GrpcContentType = "application/grpc"; internal const string GrpcWebContentType = "application/grpc-web"; internal const string GrpcWebTextContentType = "application/grpc-web-text"; - -#if NET5_0_OR_GREATER internal static readonly string Http2Protocol = HttpProtocol.Http2; -#else - internal const string Http2Protocol = "HTTP/2"; - internal const string Http20Protocol = "HTTP/2.0"; // This is what IIS sets -#endif - -#if NET5_0_OR_GREATER internal static readonly string TimeoutHeader = HeaderNames.GrpcTimeout; -#else - internal const string TimeoutHeader = "grpc-timeout"; -#endif - -#if NET5_0_OR_GREATER internal static readonly string MessageEncodingHeader = HeaderNames.GrpcEncoding; -#else - internal const string MessageEncodingHeader = "grpc-encoding"; -#endif - -#if NET5_0_OR_GREATER internal static readonly string MessageAcceptEncodingHeader = HeaderNames.GrpcAcceptEncoding; -#else - internal const string MessageAcceptEncodingHeader = "grpc-accept-encoding"; -#endif - internal const string CompressionRequestAlgorithmHeader = "grpc-internal-encoding-request"; - -#if NET5_0_OR_GREATER internal static readonly string StatusTrailer = HeaderNames.GrpcStatus; -#else - internal const string StatusTrailer = "grpc-status"; -#endif - -#if NET5_0_OR_GREATER internal static readonly string MessageTrailer = HeaderNames.GrpcMessage; -#else - internal const string MessageTrailer = "grpc-message"; -#endif - internal const string IdentityGrpcEncoding = "identity"; internal const int Http2ResetStreamCancel = 0x8; -#if NET6_0_OR_GREATER internal const int Http3ResetStreamCancel = 0x010c; -#endif internal static readonly HashSet FilteredHeaders = new HashSet(StringComparer.OrdinalIgnoreCase) { @@ -97,20 +62,14 @@ internal static class GrpcProtocolConstants [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static bool IsHttp2(string protocol) { -#if NET5_0_OR_GREATER return HttpProtocol.IsHttp2(protocol); -#else - return protocol == Http2Protocol || protocol == Http20Protocol; -#endif } -#if NET6_0_OR_GREATER [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static bool IsHttp3(string protocol) { return HttpProtocol.IsHttp3(protocol); } -#endif internal static bool IsGrpcEncodingIdentity(string encoding) { @@ -120,14 +79,8 @@ internal static bool IsGrpcEncodingIdentity(string encoding) internal static int GetCancelErrorCode(string protocol) { -#if NET6_0_OR_GREATER return IsHttp3(protocol) ? Http3ResetStreamCancel : Http2ResetStreamCancel; -#else - return Http2ResetStreamCancel; -#endif } -#if NET5_0_OR_GREATER internal const DynamicallyAccessedMemberTypes ServiceAccessibility = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods; -#endif } diff --git a/src/Grpc.AspNetCore.Server/Internal/GrpcServiceOptionsSetup.cs b/src/Grpc.AspNetCore.Server/Internal/GrpcServiceOptionsSetup.cs index dd1ada872..f2fad234e 100644 --- a/src/Grpc.AspNetCore.Server/Internal/GrpcServiceOptionsSetup.cs +++ b/src/Grpc.AspNetCore.Server/Internal/GrpcServiceOptionsSetup.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -39,9 +39,8 @@ public void Configure(GrpcServiceOptions options) if (options._compressionProviders == null || options._compressionProviders.Count == 0) { options.CompressionProviders.Add(new GzipCompressionProvider(CompressionLevel.Fastest)); -#if NET6_0_OR_GREATER + options.CompressionProviders.Add(new DeflateCompressionProvider(CompressionLevel.Fastest)); -#endif } } } diff --git a/src/Grpc.AspNetCore.Server/Internal/HttpContextServerCallContext.cs b/src/Grpc.AspNetCore.Server/Internal/HttpContextServerCallContext.cs index 5e1d51fa2..f4ef272e0 100644 --- a/src/Grpc.AspNetCore.Server/Internal/HttpContextServerCallContext.cs +++ b/src/Grpc.AspNetCore.Server/Internal/HttpContextServerCallContext.cs @@ -411,14 +411,12 @@ public void Initialize(ISystemClock? clock = null) private Activity? GetHostActivity() { -#if NET6_0_OR_GREATER // Feature always returns the host activity var feature = HttpContext.Features.Get(); if (feature != null) { return feature.Activity; } -#endif // If feature isn't available, or not supported, then fallback to Activity.Current. var activity = Activity.Current; diff --git a/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamWriter.cs b/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamWriter.cs index b6a67f9fd..8a96d9fa1 100644 --- a/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamWriter.cs +++ b/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamWriter.cs @@ -62,13 +62,11 @@ public Task WriteAsync(TResponse message) return WriteCoreAsync(message, CancellationToken.None); } -#if NET5_0_OR_GREATER // Explicit implementation because this WriteAsync has a default interface implementation. Task IAsyncStreamWriter.WriteAsync(TResponse message, CancellationToken cancellationToken) { return WriteCoreAsync(message, cancellationToken); } -#endif private async Task WriteCoreAsync(TResponse message, CancellationToken cancellationToken) { diff --git a/src/Grpc.AspNetCore.Server/Internal/PipeExtensions.cs b/src/Grpc.AspNetCore.Server/Internal/PipeExtensions.cs index ed2796638..e1f23326f 100644 --- a/src/Grpc.AspNetCore.Server/Internal/PipeExtensions.cs +++ b/src/Grpc.AspNetCore.Server/Internal/PipeExtensions.cs @@ -20,9 +20,7 @@ using System.Buffers.Binary; using System.Diagnostics; using System.IO.Pipelines; -#if NET6_0_OR_GREATER using System.Runtime.CompilerServices; -#endif using Grpc.Core; using Grpc.Net.Compression; using Microsoft.Extensions.Logging; @@ -293,9 +291,7 @@ 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 { diff --git a/src/Grpc.AspNetCore.Server/Internal/ServerCallHandlerFactory.cs b/src/Grpc.AspNetCore.Server/Internal/ServerCallHandlerFactory.cs index c1426dd18..9d41c3520 100644 --- a/src/Grpc.AspNetCore.Server/Internal/ServerCallHandlerFactory.cs +++ b/src/Grpc.AspNetCore.Server/Internal/ServerCallHandlerFactory.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -31,11 +31,7 @@ namespace Grpc.AspNetCore.Server.Internal; /// /// Creates server call handlers. Provides a place to get services that call handlers will use. /// -internal partial class ServerCallHandlerFactory< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService> where TService : class +internal partial class ServerCallHandlerFactory<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> where TService : class { private readonly ILoggerFactory _loggerFactory; private readonly IGrpcServiceActivator _serviceActivator; diff --git a/src/Grpc.AspNetCore.Server/Model/IServiceMethodProvider.cs b/src/Grpc.AspNetCore.Server/Model/IServiceMethodProvider.cs index d5778cc23..b771149bc 100644 --- a/src/Grpc.AspNetCore.Server/Model/IServiceMethodProvider.cs +++ b/src/Grpc.AspNetCore.Server/Model/IServiceMethodProvider.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -31,11 +31,7 @@ namespace Grpc.AspNetCore.Server.Model; /// instances are invoked in the order they are registered. /// /// -public interface IServiceMethodProvider< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService> where TService : class +public interface IServiceMethodProvider<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> where TService : class { /// /// Called to execute the provider. diff --git a/src/Grpc.AspNetCore.Server/Model/Internal/BinderServiceModelProvider.cs b/src/Grpc.AspNetCore.Server/Model/Internal/BinderServiceModelProvider.cs index 68473e105..db6fce070 100644 --- a/src/Grpc.AspNetCore.Server/Model/Internal/BinderServiceModelProvider.cs +++ b/src/Grpc.AspNetCore.Server/Model/Internal/BinderServiceModelProvider.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -24,11 +24,7 @@ namespace Grpc.AspNetCore.Server.Model.Internal; -internal class BinderServiceMethodProvider< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService> : IServiceMethodProvider where TService : class +internal class BinderServiceMethodProvider<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> : IServiceMethodProvider where TService : class { private readonly ILogger> _logger; diff --git a/src/Grpc.AspNetCore.Server/Model/Internal/ProviderServiceBinder.cs b/src/Grpc.AspNetCore.Server/Model/Internal/ProviderServiceBinder.cs index f570dae64..84be01989 100644 --- a/src/Grpc.AspNetCore.Server/Model/Internal/ProviderServiceBinder.cs +++ b/src/Grpc.AspNetCore.Server/Model/Internal/ProviderServiceBinder.cs @@ -24,11 +24,7 @@ namespace Grpc.AspNetCore.Server.Model.Internal; -internal class ProviderServiceBinder< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService> : ServiceBinderBase where TService : class +internal class ProviderServiceBinder<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> : ServiceBinderBase where TService : class { private readonly ServiceMethodProviderContext _context; private readonly Type _declaringType; diff --git a/src/Grpc.AspNetCore.Server/Model/Internal/ServiceRouteBuilder.cs b/src/Grpc.AspNetCore.Server/Model/Internal/ServiceRouteBuilder.cs index 7be1f3ba1..83d8875ae 100644 --- a/src/Grpc.AspNetCore.Server/Model/Internal/ServiceRouteBuilder.cs +++ b/src/Grpc.AspNetCore.Server/Model/Internal/ServiceRouteBuilder.cs @@ -19,21 +19,15 @@ using System.Diagnostics.CodeAnalysis; using Grpc.AspNetCore.Server.Internal; using Grpc.Core; -using Grpc.Shared; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; -using Microsoft.AspNetCore.Routing.Patterns; using Microsoft.Extensions.Logging; using Log = Grpc.AspNetCore.Server.Model.Internal.ServiceRouteBuilderLog; namespace Grpc.AspNetCore.Server.Model.Internal; -internal class ServiceRouteBuilder< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService> where TService : class +internal class ServiceRouteBuilder<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> where TService : class { private readonly IEnumerable> _serviceMethodProviders; private readonly ServerCallHandlerFactory _serverCallHandlerFactory; diff --git a/src/Grpc.AspNetCore.Server/Model/ServiceMethodProviderContext.cs b/src/Grpc.AspNetCore.Server/Model/ServiceMethodProviderContext.cs index 476f50053..9b283bc22 100644 --- a/src/Grpc.AspNetCore.Server/Model/ServiceMethodProviderContext.cs +++ b/src/Grpc.AspNetCore.Server/Model/ServiceMethodProviderContext.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -29,11 +29,7 @@ namespace Grpc.AspNetCore.Server.Model; /// A context for . /// /// Service type for the context. -public class ServiceMethodProviderContext< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService> where TService : class +public class ServiceMethodProviderContext<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> where TService : class { private readonly ServerCallHandlerFactory _serverCallHandlerFactory; diff --git a/src/Grpc.AspNetCore.Web/Internal/GrpcWebProtocolConstants.cs b/src/Grpc.AspNetCore.Web/Internal/GrpcWebProtocolConstants.cs index f1d1f4161..512256506 100644 --- a/src/Grpc.AspNetCore.Web/Internal/GrpcWebProtocolConstants.cs +++ b/src/Grpc.AspNetCore.Web/Internal/GrpcWebProtocolConstants.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -25,10 +25,5 @@ internal static class GrpcWebProtocolConstants internal const string GrpcContentType = "application/grpc"; internal const string GrpcWebContentType = "application/grpc-web"; internal const string GrpcWebTextContentType = "application/grpc-web-text"; - -#if NET5_0_OR_GREATER internal static readonly string Http2Protocol = HttpProtocol.Http2; -#else - internal const string Http2Protocol = "HTTP/2"; -#endif } diff --git a/src/Shared/Server/BindMethodFinder.cs b/src/Shared/Server/BindMethodFinder.cs index 45d3c8c3f..d48fdb90d 100644 --- a/src/Shared/Server/BindMethodFinder.cs +++ b/src/Shared/Server/BindMethodFinder.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -65,10 +65,8 @@ internal static class BindMethodFinder return null; } -#if NET5_0_OR_GREATER [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2075:UnrecognizedReflectionPattern", Justification = "Fallback doesn't have BindServiceMethodAttribute so can't be verified.")] -#endif internal static MethodInfo? GetBindMethodFallback(Type serviceType) { // Search for the generated service base class diff --git a/src/Shared/Server/ClientStreamingServerMethodInvoker.cs b/src/Shared/Server/ClientStreamingServerMethodInvoker.cs index 9b2c7498c..efbad4804 100644 --- a/src/Shared/Server/ClientStreamingServerMethodInvoker.cs +++ b/src/Shared/Server/ClientStreamingServerMethodInvoker.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -31,11 +31,7 @@ namespace Grpc.Shared.Server; /// Service type for this method. /// Request message type for this method. /// Response message type for this method. -internal sealed class ClientStreamingServerMethodInvoker< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService, TRequest, TResponse> : ServerMethodInvokerBase +internal sealed class ClientStreamingServerMethodInvoker<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerMethodInvokerBase where TRequest : class where TResponse : class where TService : class diff --git a/src/Shared/Server/DuplexStreamingServerMethodInvoker.cs b/src/Shared/Server/DuplexStreamingServerMethodInvoker.cs index 33aa1f0e9..e195fb88f 100644 --- a/src/Shared/Server/DuplexStreamingServerMethodInvoker.cs +++ b/src/Shared/Server/DuplexStreamingServerMethodInvoker.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -31,11 +31,7 @@ namespace Grpc.Shared.Server; /// Service type for this method. /// Request message type for this method. /// Response message type for this method. -internal sealed class DuplexStreamingServerMethodInvoker< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService, TRequest, TResponse> : ServerMethodInvokerBase +internal sealed class DuplexStreamingServerMethodInvoker<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerMethodInvokerBase where TRequest : class where TResponse : class where TService : class diff --git a/src/Shared/Server/ServerMethodInvokerBase.cs b/src/Shared/Server/ServerMethodInvokerBase.cs index 247a069c2..b2afd3ef4 100644 --- a/src/Shared/Server/ServerMethodInvokerBase.cs +++ b/src/Shared/Server/ServerMethodInvokerBase.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -29,11 +29,7 @@ namespace Grpc.Shared.Server; /// Service type for this method. /// Request message type for this method. /// Response message type for this method. -internal abstract class ServerMethodInvokerBase< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService, TRequest, TResponse> +internal abstract class ServerMethodInvokerBase<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> where TRequest : class where TResponse : class where TService : class diff --git a/src/Shared/Server/ServerStreamingServerMethodInvoker.cs b/src/Shared/Server/ServerStreamingServerMethodInvoker.cs index db93b7cc4..268e17463 100644 --- a/src/Shared/Server/ServerStreamingServerMethodInvoker.cs +++ b/src/Shared/Server/ServerStreamingServerMethodInvoker.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -31,11 +31,7 @@ namespace Grpc.Shared.Server; /// Service type for this method. /// Request message type for this method. /// Response message type for this method. -internal sealed class ServerStreamingServerMethodInvoker< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService, TRequest, TResponse> : ServerMethodInvokerBase +internal sealed class ServerStreamingServerMethodInvoker<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerMethodInvokerBase where TRequest : class where TResponse : class where TService : class diff --git a/src/Shared/Server/UnaryServerMethodInvoker.cs b/src/Shared/Server/UnaryServerMethodInvoker.cs index c81c3d7a0..cbd1115fc 100644 --- a/src/Shared/Server/UnaryServerMethodInvoker.cs +++ b/src/Shared/Server/UnaryServerMethodInvoker.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -32,11 +32,7 @@ namespace Grpc.Shared.Server; /// Service type for this method. /// Request message type for this method. /// Response message type for this method. -internal sealed class UnaryServerMethodInvoker< -#if NET5_0_OR_GREATER - [DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] -#endif - TService, TRequest, TResponse> : ServerMethodInvokerBase +internal sealed class UnaryServerMethodInvoker<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerMethodInvokerBase where TRequest : class where TResponse : class where TService : class diff --git a/test/FunctionalTests/Balancer/BalancerHelpers.cs b/test/FunctionalTests/Balancer/BalancerHelpers.cs index 9fc61edf1..2406c40eb 100644 --- a/test/FunctionalTests/Balancer/BalancerHelpers.cs +++ b/test/FunctionalTests/Balancer/BalancerHelpers.cs @@ -238,7 +238,6 @@ public TestSubchannelTransportFactory(TimeSpan socketPingInterval, TimeSpan? con public ISubchannelTransport Create(Subchannel subchannel) { -#if NET5_0_OR_GREATER return new SocketConnectivitySubchannelTransport( subchannel, _socketPingInterval, @@ -246,9 +245,6 @@ public ISubchannelTransport Create(Subchannel subchannel) _connectionIdleTimeout, subchannel._manager.LoggerFactory, _socketConnect); -#else - return new PassiveSubchannelTransport(subchannel); -#endif } } } diff --git a/test/FunctionalTests/Balancer/RoundRobinBalancerTests.cs b/test/FunctionalTests/Balancer/RoundRobinBalancerTests.cs index 9f79cf7e2..19686b10d 100644 --- a/test/FunctionalTests/Balancer/RoundRobinBalancerTests.cs +++ b/test/FunctionalTests/Balancer/RoundRobinBalancerTests.cs @@ -17,7 +17,6 @@ #endregion #if SUPPORT_LOAD_BALANCING -#if NET5_0_OR_GREATER using System; using System.Collections.Generic; @@ -462,4 +461,3 @@ Task UnaryMethod(HelloRequest request, ServerCallContext context) } #endif -#endif diff --git a/test/FunctionalTests/Client/CompressionTests.cs b/test/FunctionalTests/Client/CompressionTests.cs index 27d745262..1444355fd 100644 --- a/test/FunctionalTests/Client/CompressionTests.cs +++ b/test/FunctionalTests/Client/CompressionTests.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -31,9 +31,7 @@ public class CompressionTests : FunctionalTestBase { [TestCase("identity")] [TestCase("gzip")] -#if NET6_0_OR_GREATER [TestCase("deflate")] -#endif public async Task SendCompressedMessage_ServiceCompressionConfigured_ResponseGzipEncoding(string algorithmName) { // Arrange diff --git a/test/FunctionalTests/Client/ConnectionTests.cs b/test/FunctionalTests/Client/ConnectionTests.cs index a5c118577..578230229 100644 --- a/test/FunctionalTests/Client/ConnectionTests.cs +++ b/test/FunctionalTests/Client/ConnectionTests.cs @@ -55,24 +55,17 @@ public async Task ALPN_ProtocolDowngradedToHttp1_ThrowErrorFromServer() // Assert Assert.AreEqual(StatusCode.Internal, ex.StatusCode); -#if NET5_0_OR_GREATER var debugException = ex.Status.DebugException!; Assert.AreEqual("The SSL connection could not be established, see inner exception.", debugException.Message); -#else - Assert.AreEqual("Request protocol 'HTTP/1.1' is not supported.", ex.Status.Detail); -#endif } -#if NET5_0_OR_GREATER [Test] public async Task UnixDomainSockets() { Task UnaryUds(HelloRequest request, ServerCallContext context) { -#if NET6_0_OR_GREATER var endPoint = (UnixDomainSocketEndPoint)context.GetHttpContext().Features.Get()!.Socket.LocalEndPoint!; Assert.NotNull(endPoint); -#endif return Task.FromResult(new HelloReply { Message = "Hello " + request.Name }); } @@ -96,7 +89,6 @@ Task UnaryUds(HelloRequest request, ServerCallContext context) // Assert Assert.AreEqual("Hello John", response.Message); } -#endif #if NET7_0_OR_GREATER [Test] @@ -122,7 +114,6 @@ public async Task Http3() } #endif -#if NET5_0_OR_GREATER [Test] public async Task ShareSocketsHttpHandler() { @@ -200,5 +191,4 @@ Task Unary(HelloRequest request, ServerCallContext context) var expected = $"CONNECT {http.address.Host}:{http.address.Port} HTTP/1.1"; Assert.AreEqual(expected, proxyServer.Requests[0].RequestLine); } -#endif } diff --git a/test/FunctionalTests/Client/HedgingTests.cs b/test/FunctionalTests/Client/HedgingTests.cs index 6bbd10c4e..e23f06255 100644 --- a/test/FunctionalTests/Client/HedgingTests.cs +++ b/test/FunctionalTests/Client/HedgingTests.cs @@ -679,7 +679,6 @@ await call.RequestStream.WriteAsync( Assert.AreEqual(1, serverAbortCount); } -#if NET5_0_OR_GREATER [Test] public async Task ClientStreaming_WriteAsyncCancellationBefore_ClientAbort() { @@ -949,5 +948,4 @@ async Task ClientStreamingWithReadFailures(IAsyncStreamReader ClientStreamingWithReadFailures(IAsyncStreamReader ClientStreamingWithReadFailures(IAsyncStreamReader UnaryTelemetryHeader(HelloRequest request, ServerCallContext context) { - telemetryHeader = context.RequestHeaders.GetValue( -#if NET5_0_OR_GREATER - "traceparent" -#else - "request-id" -#endif - ); + telemetryHeader = context.RequestHeaders.GetValue("traceparent"); return Task.FromResult(new HelloReply()); } @@ -82,7 +74,6 @@ Task UnaryTelemetryHeader(HelloRequest request, ServerCallContext co var client = CreateClient(clientType, method, handler); // Act -#if NET5_0_OR_GREATER var result = new List>(); using var allSubscription = new AllListenersObserver(new Dictionary>> @@ -90,21 +81,17 @@ Task UnaryTelemetryHeader(HelloRequest request, ServerCallContext co ["HttpHandlerDiagnosticListener"] = new ObserverToList>(result) }); using (DiagnosticListener.AllListeners.Subscribe(allSubscription)) -#endif { await client.UnaryCall(new HelloRequest()).ResponseAsync.DefaultTimeout(); } // Assert Assert.IsNotNull(telemetryHeader); - -#if NET5_0_OR_GREATER Assert.AreEqual(4, result.Count); Assert.AreEqual("System.Net.Http.HttpRequestOut.Start", result[0].Key); Assert.AreEqual("System.Net.Http.Request", result[1].Key); Assert.AreEqual("System.Net.Http.HttpRequestOut.Stop", result[2].Key); Assert.AreEqual("System.Net.Http.Response", result[3].Key); -#endif } private TestClient CreateClient(ClientType clientType, Method method, HttpMessageHandler? handler) diff --git a/test/FunctionalTests/Client/UnaryTests.cs b/test/FunctionalTests/Client/UnaryTests.cs index bc58012ff..368919615 100644 --- a/test/FunctionalTests/Client/UnaryTests.cs +++ b/test/FunctionalTests/Client/UnaryTests.cs @@ -128,7 +128,6 @@ Task UnaryThrowError(HelloRequest request, ServerCallContext context Assert.AreEqual(expectedServerCulture, serverCulture); } -#if NET5_0_OR_GREATER [Test] public async Task MaxConcurrentStreams_StartConcurrently_AdditionalConnectionsCreated() { @@ -226,7 +225,6 @@ async Task UnaryThrowError(HelloRequest request, ServerCallContext c } } } -#endif [Test] public async Task Health_Check_Success() diff --git a/test/FunctionalTests/Infrastructure/GrpcHttpHelper.cs b/test/FunctionalTests/Infrastructure/GrpcHttpHelper.cs index f631e498b..c32b4ab0e 100644 --- a/test/FunctionalTests/Infrastructure/GrpcHttpHelper.cs +++ b/test/FunctionalTests/Infrastructure/GrpcHttpHelper.cs @@ -24,9 +24,7 @@ public static HttpRequestMessage Create(string url, HttpMethod? method = null) { var request = new HttpRequestMessage(method ?? HttpMethod.Post, url); request.Version = new Version(2, 0); -#if NET5_0_OR_GREATER request.VersionPolicy = HttpVersionPolicy.RequestVersionExact; -#endif return request; } diff --git a/test/FunctionalTests/Infrastructure/GrpcTestFixture.cs b/test/FunctionalTests/Infrastructure/GrpcTestFixture.cs index 6c2c61e14..5422fcfba 100644 --- a/test/FunctionalTests/Infrastructure/GrpcTestFixture.cs +++ b/test/FunctionalTests/Infrastructure/GrpcTestFixture.cs @@ -73,9 +73,7 @@ public static IPEndpointInfoContainer Create(ListenOptions listenOptions, bool i public class GrpcTestFixture : IDisposable where TStartup : class { -#if NET5_0_OR_GREATER private readonly string _socketPath = Path.GetTempFileName(); -#endif private readonly InProcessTestServer _server; public GrpcTestFixture( @@ -143,7 +141,6 @@ public GrpcTestFixture( urls[TestServerEndpointName.Http1WithTls] = IPEndpointInfoContainer.Create(listenOptions, isHttps: true); }); -#if NET5_0_OR_GREATER if (File.Exists(_socketPath)) { File.Delete(_socketPath); @@ -155,9 +152,7 @@ public GrpcTestFixture( urls[TestServerEndpointName.UnixDomainSocket] = new SocketsEndpointInfoContainer(_socketPath); }); -#endif -#if NET6_0_OR_GREATER if (RequireHttp3Attribute.IsSupported(out _)) { var http3Port = Convert.ToInt32(context.Configuration["Http3Port"], CultureInfo.InvariantCulture); @@ -175,16 +170,13 @@ public GrpcTestFixture( urls[TestServerEndpointName.Http3WithTls] = IPEndpointInfoContainer.Create(listenOptions, isHttps: true); }); } -#endif }); _server.StartServer(); DynamicGrpc = _server.Host!.Services.GetRequiredService(); -#if !NET5_0 AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); -#endif (Client, Handler) = CreateHttpCore(defaultClientEndpointName); } @@ -221,7 +213,6 @@ public HttpClient CreateClient(TestServerEndpointName? endpointName = null, Dele configureHandler?.Invoke(socketsHttpHandler); -#if NET5_0_OR_GREATER if (endpointName == TestServerEndpointName.UnixDomainSocket) { var udsEndPoint = new UnixDomainSocketEndPoint(_server.GetUrl(endpointName.Value)); @@ -229,7 +220,6 @@ public HttpClient CreateClient(TestServerEndpointName? endpointName = null, Dele socketsHttpHandler.ConnectCallback = connectionFactory.ConnectAsync; } -#endif HttpClient client; HttpMessageHandler handler; @@ -243,23 +233,19 @@ public HttpClient CreateClient(TestServerEndpointName? endpointName = null, Dele handler = socketsHttpHandler; } -#if NET6_0_OR_GREATER if (endpointName == TestServerEndpointName.Http3WithTls) { // TODO(JamesNK): There is a bug with SocketsHttpHandler and HTTP/3 that prevents calls // upgrading from 2 to 3. Force HTTP/3 calls to require that protocol. handler = new Http3DelegatingHandler(handler); } -#endif client = new HttpClient(handler); if (endpointName == TestServerEndpointName.Http2) { client.DefaultRequestVersion = new Version(2, 0); -#if NET5_0_OR_GREATER client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher; -#endif } client.BaseAddress = CalculateBaseAddress(endpointName.Value); @@ -269,12 +255,10 @@ public HttpClient CreateClient(TestServerEndpointName? endpointName = null, Dele private Uri CalculateBaseAddress(TestServerEndpointName endpointName) { -#if NET5_0_OR_GREATER if (endpointName == TestServerEndpointName.UnixDomainSocket) { return new Uri("http://localhost"); } -#endif return new Uri(_server.GetUrl(endpointName)); } @@ -287,14 +271,10 @@ public Uri GetUrl(TestServerEndpointName endpointName) case TestServerEndpointName.Http2: case TestServerEndpointName.Http1WithTls: case TestServerEndpointName.Http2WithTls: -#if NET6_0_OR_GREATER case TestServerEndpointName.Http3WithTls: -#endif return new Uri(_server.GetUrl(endpointName)); -#if NET5_0_OR_GREATER case TestServerEndpointName.UnixDomainSocket: return new Uri("http://localhost"); -#endif default: throw new ArgumentException("Unexpected value: " + endpointName, nameof(endpointName)); } @@ -310,16 +290,13 @@ public void Dispose() { Client.Dispose(); _server.Dispose(); -#if NET5_0_OR_GREATER if (File.Exists(_socketPath)) { File.Delete(_socketPath); } -#endif } -#if NET6_0_OR_GREATER -private class Http3DelegatingHandler : DelegatingHandler + private class Http3DelegatingHandler : DelegatingHandler { public Http3DelegatingHandler(HttpMessageHandler innerHandler) { @@ -333,5 +310,4 @@ protected override Task SendAsync(HttpRequestMessage reques return base.SendAsync(request, cancellationToken); } } -#endif } diff --git a/test/FunctionalTests/Infrastructure/TestServerEndpointName.cs b/test/FunctionalTests/Infrastructure/TestServerEndpointName.cs index 07b2afb35..6af5d65ee 100644 --- a/test/FunctionalTests/Infrastructure/TestServerEndpointName.cs +++ b/test/FunctionalTests/Infrastructure/TestServerEndpointName.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -24,10 +24,6 @@ public enum TestServerEndpointName Http1, Http2WithTls, Http1WithTls, -#if NET5_0_OR_GREATER UnixDomainSocket, -#endif -#if NET6_0_OR_GREATER Http3WithTls, -#endif } diff --git a/test/FunctionalTests/Infrastructure/UnixDomainSocketConnectionFactory.cs b/test/FunctionalTests/Infrastructure/UnixDomainSocketConnectionFactory.cs index f36f32f9d..10e56e483 100644 --- a/test/FunctionalTests/Infrastructure/UnixDomainSocketConnectionFactory.cs +++ b/test/FunctionalTests/Infrastructure/UnixDomainSocketConnectionFactory.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -16,7 +16,6 @@ #endregion -#if NET5_0_OR_GREATER using System; using System.IO; using System.Net; @@ -52,4 +51,3 @@ public async ValueTask ConnectAsync(SocketsHttpConnectionContext _, Canc } } } -#endif diff --git a/test/FunctionalTests/Server/CompressionTests.cs b/test/FunctionalTests/Server/CompressionTests.cs index 856e39140..a683d1510 100644 --- a/test/FunctionalTests/Server/CompressionTests.cs +++ b/test/FunctionalTests/Server/CompressionTests.cs @@ -79,9 +79,7 @@ async Task UnaryEnableCompression(HelloRequest request, ServerCallCo } [TestCase("gzip")] -#if NET6_0_OR_GREATER [TestCase("deflate")] -#endif public async Task SendCompressedMessage_UnaryEnabledInCall_CompressedMessageReturned(string algorithmName) { async Task UnaryEnableCompression(HelloRequest request, ServerCallContext context) @@ -128,9 +126,7 @@ async Task UnaryEnableCompression(HelloRequest request, ServerCallCo } [TestCase("gzip")] -#if NET6_0_OR_GREATER [TestCase("deflate")] -#endif public async Task SendCompressedMessage_ServerStreamingEnabledInCall_CompressedMessageReturned(string algorithmName) { async Task ServerStreamingEnableCompression(HelloRequest request, IServerStreamWriter responseStream, ServerCallContext context) @@ -191,9 +187,7 @@ async Task ServerStreamingEnableCompression(HelloRequest request, IServerStreamW } [TestCase("gzip")] -#if NET6_0_OR_GREATER [TestCase("deflate")] -#endif public async Task SendCompressedMessage_ServiceHasNoCompressionConfigured_ResponseIdentityEncoding(string algorithmName) { // Arrange @@ -222,9 +216,7 @@ public async Task SendCompressedMessage_ServiceHasNoCompressionConfigured_Respon } [TestCase("gzip")] -#if NET6_0_OR_GREATER [TestCase("deflate")] -#endif public async Task SendCompressedMessageWithIdentity_ReturnInternalError(string algorithmName) { // Arrange @@ -291,12 +283,7 @@ public async Task SendUnsupportedEncodingHeaderWithUncompressedMessage_ReturnUnc public async Task SendCompressedMessageWithUnsupportedEncoding_ReturnUnimplemented() { // Arrange - var expectedError = -#if NET6_0_OR_GREATER - "Unsupported grpc-encoding value 'DOES_NOT_EXIST'. Supported encodings: identity, gzip, deflate"; -#else - "Unsupported grpc-encoding value 'DOES_NOT_EXIST'. Supported encodings: identity, gzip"; -#endif + var expectedError = "Unsupported grpc-encoding value 'DOES_NOT_EXIST'. Supported encodings: identity, gzip, deflate"; SetExpectedErrorsFilter(writeContext => { @@ -335,11 +322,7 @@ public async Task SendCompressedMessageWithUnsupportedEncoding_ReturnUnimplement // Assert Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); -#if NET6_0_OR_GREATER Assert.AreEqual("identity,gzip,deflate", response.Headers.GetValues(GrpcProtocolConstants.MessageAcceptEncodingHeader).Single()); -#else - Assert.AreEqual("identity,gzip", response.Headers.GetValues(GrpcProtocolConstants.MessageAcceptEncodingHeader).Single()); -#endif response.AssertTrailerStatus(StatusCode.Unimplemented, expectedError); @@ -389,9 +372,7 @@ public override long Position } [TestCase("gzip")] -#if NET6_0_OR_GREATER [TestCase("deflate")] -#endif public async Task SendCompressedMessageWithoutEncodingHeader_ServerErrorResponse(string algorithmName) { // Arrange @@ -432,9 +413,7 @@ public async Task SendCompressedMessageWithoutEncodingHeader_ServerErrorResponse [TestCase("gzip", "gzip", true)] [TestCase("gzip", "identity, gzip", true)] [TestCase("gzip", "gzip ", true)] -#if NET6_0_OR_GREATER [TestCase("deflate", "deflate", false)] -#endif public async Task SendCompressedMessageAndReturnResultWithNoCompressFlag_ResponseNotCompressed(string algorithmName, string messageAcceptEncoding, bool algorithmSupportedByServer) { // Arrange @@ -473,9 +452,7 @@ public async Task SendCompressedMessageAndReturnResultWithNoCompressFlag_Respons } [TestCase("gzip", true)] -#if NET6_0_OR_GREATER [TestCase("deflate", false)] -#endif public async Task SendUncompressedMessageToServiceWithCompression_ResponseCompressed(string algorithmName, bool algorithmSupportedByServer) { // Arrange diff --git a/test/FunctionalTests/TestServer/Helpers/GrpcTestFixture.cs b/test/FunctionalTests/TestServer/Helpers/GrpcTestFixture.cs index cb5782671..a7c931592 100644 --- a/test/FunctionalTests/TestServer/Helpers/GrpcTestFixture.cs +++ b/test/FunctionalTests/TestServer/Helpers/GrpcTestFixture.cs @@ -58,14 +58,10 @@ public GrpcTestFixture(Action? initialConfigureServices) _host = builder.Start(); _server = _host.GetTestServer(); -#if !NET5_0 // Need to set the response version to 2.0. // Required because of this TestServer issue - https://github.com/aspnet/AspNetCore/issues/16940 var handler = new ResponseVersionHandler(); handler.InnerHandler = _server.CreateHandler(); -#else - var handler = _server.CreateHandler(); -#endif var client = new HttpClient(handler); client.BaseAddress = new Uri("http://localhost"); @@ -84,7 +80,6 @@ public void Dispose() _server.Dispose(); } -#if !NET5_0 private class ResponseVersionHandler : DelegatingHandler { protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) @@ -95,7 +90,6 @@ protected override async Task SendAsync(HttpRequestMessage return response; } } -#endif public IDisposable GetTestContext() { diff --git a/test/FunctionalTests/Web/Client/ConnectionTests.cs b/test/FunctionalTests/Web/Client/ConnectionTests.cs index f544f029e..fcd47eaa6 100644 --- a/test/FunctionalTests/Web/Client/ConnectionTests.cs +++ b/test/FunctionalTests/Web/Client/ConnectionTests.cs @@ -70,23 +70,15 @@ private static IEnumerable ConnectionTestData() yield return new TestCaseData(TestServerEndpointName.Http2, "2.0", true); yield return new TestCaseData(TestServerEndpointName.Http2, "1.1", false); yield return new TestCaseData(TestServerEndpointName.Http2, null, true); -#if NET5_0_OR_GREATER // Specifing HTTP/2 doesn't work when the server is using TLS with HTTP/1.1 // Caused by using HttpVersionPolicy.RequestVersionOrHigher setting yield return new TestCaseData(TestServerEndpointName.Http1WithTls, "2.0", false); -#else - yield return new TestCaseData(TestServerEndpointName.Http1WithTls, "2.0", true); -#endif yield return new TestCaseData(TestServerEndpointName.Http1WithTls, "1.1", true); yield return new TestCaseData(TestServerEndpointName.Http1WithTls, null, true); yield return new TestCaseData(TestServerEndpointName.Http2WithTls, "2.0", true); -#if NET5_0_OR_GREATER // Specifing HTTP/1.1 does work when the server is using TLS with HTTP/2 // Caused by using HttpVersionPolicy.RequestVersionOrHigher setting yield return new TestCaseData(TestServerEndpointName.Http2WithTls, "1.1", true); -#else - yield return new TestCaseData(TestServerEndpointName.Http2WithTls, "1.1", false); -#endif yield return new TestCaseData(TestServerEndpointName.Http2WithTls, null, true); #if NET7_0_OR_GREATER yield return new TestCaseData(TestServerEndpointName.Http3WithTls, null, true); @@ -107,13 +99,11 @@ public async Task SendValidRequest_WithConnectionOptionsOnChannel(TestServerEndp private async Task SendRequestWithConnectionOptionsCore(TestServerEndpointName endpointName, string? version, bool success, bool setVersionOnHandler) { -#if NET6_0_OR_GREATER if (endpointName == TestServerEndpointName.Http3WithTls && !RequireHttp3Attribute.IsSupported(out var message)) { Assert.Ignore(message); } -#endif SetExpectedErrorsFilter(writeContext => { diff --git a/test/FunctionalTests/Web/GrpcWebFunctionalTestBase.cs b/test/FunctionalTests/Web/GrpcWebFunctionalTestBase.cs index 4e6cabc5e..8dc8c2385 100644 --- a/test/FunctionalTests/Web/GrpcWebFunctionalTestBase.cs +++ b/test/FunctionalTests/Web/GrpcWebFunctionalTestBase.cs @@ -40,13 +40,11 @@ protected GrpcWebFunctionalTestBase(GrpcTestMode grpcTestMode, TestServerEndpoin GrpcTestMode = grpcTestMode; EndpointName = endpointName; -#if NET6_0_OR_GREATER if (endpointName == TestServerEndpointName.Http3WithTls && !RequireHttp3Attribute.IsSupported(out var message)) { Assert.Ignore(message); } -#endif } protected HttpClient CreateGrpcWebClient() @@ -71,12 +69,10 @@ protected HttpClient CreateGrpcWebClient() { protocol = new Version(1, 1); } -#if NET6_0_OR_GREATER else if (EndpointName == TestServerEndpointName.Http3WithTls) { protocol = new Version(3, 0); } -#endif else { protocol = new Version(2, 0); diff --git a/test/Grpc.AspNetCore.Server.Tests/CallHandlerTests.cs b/test/Grpc.AspNetCore.Server.Tests/CallHandlerTests.cs index 369495fbb..4f3af453a 100644 --- a/test/Grpc.AspNetCore.Server.Tests/CallHandlerTests.cs +++ b/test/Grpc.AspNetCore.Server.Tests/CallHandlerTests.cs @@ -150,27 +150,6 @@ public async Task ProtocolValidation_InvalidProtocol_FailureLogged() Assert.AreEqual("Request protocol of 'HTTP/1.1' is not supported.", log!.Message); } -#if !NET5_0_OR_GREATER - // .NET Core 3.0 + IIS returned HTTP/2.0 as the protocol - [Test] - public async Task ProtocolValidation_IISHttp2Protocol_Success() - { - // Arrange - var testSink = new TestSink(); - var testLoggerFactory = new TestLoggerFactory(testSink, true); - - var httpContext = HttpContextHelpers.CreateContext(protocol: GrpcProtocolConstants.Http20Protocol); - var call = CreateHandler(MethodType.ClientStreaming, testLoggerFactory); - - // Act - await call.HandleCallAsync(httpContext).DefaultTimeout(); - - // Assert - var log = testSink.Writes.SingleOrDefault(w => w.EventId.Name == "UnsupportedRequestProtocol"); - Assert.IsNull(log); - } -#endif - #if NET8_0_OR_GREATER [TestCase(MethodType.Unary, false)] [TestCase(MethodType.ClientStreaming, true)] diff --git a/test/Grpc.AspNetCore.Server.Tests/GrpcServicesExtensionsTests.cs b/test/Grpc.AspNetCore.Server.Tests/GrpcServicesExtensionsTests.cs index a1f3ad5fc..f5f756ca0 100644 --- a/test/Grpc.AspNetCore.Server.Tests/GrpcServicesExtensionsTests.cs +++ b/test/Grpc.AspNetCore.Server.Tests/GrpcServicesExtensionsTests.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -48,14 +48,9 @@ public void AddGrpc_ConfigureOptions_OptionsSet() Assert.AreEqual(GrpcServiceOptionsSetup.DefaultReceiveMaxMessageSize, options.MaxReceiveMessageSize); Assert.AreEqual(1, options.MaxSendMessageSize); -#if NET6_0_OR_GREATER Assert.AreEqual(2, options.CompressionProviders.Count); Assert.AreEqual("gzip", options.CompressionProviders[0].EncodingName); Assert.AreEqual("deflate", options.CompressionProviders[1].EncodingName); -#else - Assert.AreEqual(1, options.CompressionProviders.Count); - Assert.AreEqual("gzip", options.CompressionProviders[0].EncodingName); -#endif } [Test] diff --git a/test/Grpc.AspNetCore.Server.Tests/HttpContextServerCallContextTests.cs b/test/Grpc.AspNetCore.Server.Tests/HttpContextServerCallContextTests.cs index 63f357cff..fd4a6aff8 100644 --- a/test/Grpc.AspNetCore.Server.Tests/HttpContextServerCallContextTests.cs +++ b/test/Grpc.AspNetCore.Server.Tests/HttpContextServerCallContextTests.cs @@ -603,9 +603,7 @@ public void RequestHeaders_ManyHttpRequestHeaders_HeadersFiltered(string headerN } [TestCase("HTTP/2", GrpcProtocolConstants.Http2ResetStreamCancel)] -#if NET6_0_OR_GREATER [TestCase("HTTP/3", GrpcProtocolConstants.Http3ResetStreamCancel)] -#endif public Task EndCallAsync_LongRunningDeadlineAbort_WaitsUntilDeadlineAbortIsFinished( string protocol, int expectedResetCode) @@ -618,9 +616,7 @@ public Task EndCallAsync_LongRunningDeadlineAbort_WaitsUntilDeadlineAbortIsFinis } [TestCase("HTTP/2", GrpcProtocolConstants.Http2ResetStreamCancel)] -#if NET6_0_OR_GREATER [TestCase("HTTP/3", GrpcProtocolConstants.Http3ResetStreamCancel)] -#endif public Task ProcessHandlerErrorAsync_LongRunningDeadlineAbort_WaitsUntilDeadlineAbortIsFinished( string protocol, int expectedResetCode) diff --git a/test/Shared/MessageHelpers.cs b/test/Shared/MessageHelpers.cs index 8858d18b3..7534a58cd 100644 --- a/test/Shared/MessageHelpers.cs +++ b/test/Shared/MessageHelpers.cs @@ -1,4 +1,4 @@ -#region Copyright notice and license +#region Copyright notice and license // Copyright 2019 The gRPC Authors // @@ -30,12 +30,10 @@ namespace Grpc.Tests.Shared; internal static class MessageHelpers { private static readonly List DefaultProviders = new List - { - new GzipCompressionProvider(CompressionLevel.Fastest), -#if NET6_0_OR_GREATER - new DeflateCompressionProvider(CompressionLevel.Fastest), -#endif - }; + { + new GzipCompressionProvider(CompressionLevel.Fastest), + new DeflateCompressionProvider(CompressionLevel.Fastest), + }; public static Marshaller GetMarshaller(MessageParser parser) where TMessage : IMessage => Marshallers.Create(r => r.ToByteArray(), data => parser.ParseFrom(data));