From 11ce430d45f7fe6a8f86582f2d7098cc104b6dd8 Mon Sep 17 00:00:00 2001 From: Henrik Gedionsen Date: Mon, 21 Oct 2024 15:23:01 +0200 Subject: [PATCH] Make some private & internal classes sealed where possible --- perf/benchmarkapps/Shared/BenchmarkServiceImpl.cs | 4 ++-- .../CallHandlers/ClientStreamingServerCallHandler.cs | 2 +- .../CallHandlers/DuplexStreamingServerCallHandler.cs | 2 +- .../CallHandlers/ServerStreamingServerCallHandler.cs | 2 +- .../Internal/CallHandlers/UnaryServerCallHandler.cs | 2 +- src/Grpc.AspNetCore.Server/Internal/GrpcMarkerService.cs | 2 +- src/Grpc.AspNetCore.Server/Internal/GrpcServerBuilder.cs | 2 +- .../Internal/GrpcServiceOptionsSetup.cs | 4 ++-- .../Internal/HttpContextStreamReader.cs | 2 +- .../Internal/HttpContextStreamWriter.cs | 2 +- .../Internal/ReadOnlySequenceStream.cs | 2 +- .../Internal/ServerCallHandlerFactory.cs | 2 +- src/Grpc.AspNetCore.Server/Internal/SystemClock.cs | 2 +- .../Model/Internal/BinderServiceModelProvider.cs | 2 +- src/Grpc.AspNetCore.Server/Model/Internal/MethodModel.cs | 2 +- .../Model/Internal/ProviderServiceBinder.cs | 2 +- .../Model/Internal/ServiceMethodsRegistry.cs | 2 +- .../Model/Internal/ServiceRouteBuilder.cs | 2 +- src/Grpc.AspNetCore.Web/Internal/Base64PipeReader.cs | 2 +- src/Grpc.AspNetCore.Web/Internal/Base64PipeWriter.cs | 4 ++-- src/Grpc.AspNetCore.Web/Internal/GrpcWebFeature.cs | 2 +- src/Grpc.AspNetCore.Web/Internal/MemorySegment.cs | 2 +- src/Grpc.Core.Api/CallCredentials.cs | 4 ++-- src/Grpc.Core.Api/ClientBase.cs | 4 ++-- src/Grpc.Core.Api/Interceptors/CallInvokerExtensions.cs | 2 +- .../Interceptors/InterceptingCallInvoker.cs | 3 +-- src/Grpc.Core.Api/Internal/UnimplementedCallInvoker.cs | 5 +---- src/Grpc.Net.Client.Web/Internal/Base64RequestStream.cs | 2 +- src/Grpc.Net.Client.Web/Internal/Base64ResponseStream.cs | 2 +- .../Internal/GrpcWebRequestContent.cs | 2 +- .../Internal/GrpcWebResponseContent.cs | 2 +- .../Internal/GrpcWebResponseStream.cs | 2 +- src/Grpc.Net.Client.Web/Internal/OperatingSystem.cs | 2 +- .../Balancer/Internal/BalancerAddressEqualityComparer.cs | 2 +- .../Balancer/Internal/BalancerHttpHandler.cs | 9 ++------- src/Grpc.Net.Client/Balancer/Internal/ErrorPicker.cs | 3 +-- .../Balancer/Internal/PassiveSubchannelTransport.cs | 6 +----- .../Internal/SocketConnectivitySubchannelTransport.cs | 4 ++-- src/Grpc.Net.Client/Balancer/PickFirstBalancer.cs | 4 +--- src/Grpc.Net.Client/Internal/GrpcCallScope.cs | 2 +- src/Grpc.Net.Client/Internal/GrpcMethodInfo.cs | 8 ++++---- src/Grpc.Net.Client/Internal/Http/PushStreamContent.cs | 2 +- src/Grpc.Net.Client/Internal/Http/PushUnaryContent.cs | 2 +- src/Grpc.Net.Client/Internal/Http/WinHttpUnaryContent.cs | 2 +- .../Internal/HttpContentClientStreamReader.cs | 2 +- .../Internal/HttpContentClientStreamWriter.cs | 2 +- .../Internal/Retry/ChannelRetryThrottling.cs | 2 +- .../Internal/Retry/RetryCallBaseClientStreamReader.cs | 2 +- .../Internal/Retry/RetryCallBaseClientStreamWriter.cs | 2 +- src/Shared/Server/InterceptorPipelineBuilder.cs | 4 ++-- src/Shared/TrailingHeadersHelpers.cs | 2 +- src/dotnet-grpc/Commands/AddFileCommand.cs | 5 +---- src/dotnet-grpc/Commands/AddUrlCommand.cs | 3 +-- src/dotnet-grpc/Commands/ListCommand.cs | 3 +-- src/dotnet-grpc/Commands/RefreshCommand.cs | 4 +--- src/dotnet-grpc/Commands/RemoveCommand.cs | 5 +---- src/dotnet-grpc/Internal/CLIToolException.cs | 2 +- src/dotnet-grpc/Internal/GrpcDependencyAttribute.cs | 2 +- 58 files changed, 69 insertions(+), 95 deletions(-) diff --git a/perf/benchmarkapps/Shared/BenchmarkServiceImpl.cs b/perf/benchmarkapps/Shared/BenchmarkServiceImpl.cs index 83c03970f..bc8ae2bb9 100644 --- a/perf/benchmarkapps/Shared/BenchmarkServiceImpl.cs +++ b/perf/benchmarkapps/Shared/BenchmarkServiceImpl.cs @@ -20,7 +20,7 @@ using Grpc.Core; using Grpc.Testing; -class BenchmarkServiceImpl : BenchmarkService.BenchmarkServiceBase +sealed class BenchmarkServiceImpl : BenchmarkService.BenchmarkServiceBase { #if CLIENT_CERTIFICATE_AUTHENTICATION [Microsoft.AspNetCore.Authorization.Authorize] @@ -98,4 +98,4 @@ public static SimpleResponse CreateResponse(SimpleRequest request) var payload = new Payload { Body = body }; return new SimpleResponse { Payload = payload }; } -} \ No newline at end of file +} diff --git a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ClientStreamingServerCallHandler.cs b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ClientStreamingServerCallHandler.cs index f6d9bb155..99437edc9 100644 --- a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ClientStreamingServerCallHandler.cs +++ b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ClientStreamingServerCallHandler.cs @@ -24,7 +24,7 @@ namespace Grpc.AspNetCore.Server.Internal.CallHandlers; -internal class ClientStreamingServerCallHandler<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerCallHandlerBase +internal sealed 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 cc5318511..2649b1fb5 100644 --- a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/DuplexStreamingServerCallHandler.cs +++ b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/DuplexStreamingServerCallHandler.cs @@ -23,7 +23,7 @@ namespace Grpc.AspNetCore.Server.Internal.CallHandlers; -internal class DuplexStreamingServerCallHandler<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerCallHandlerBase +internal sealed 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/ServerStreamingServerCallHandler.cs b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerStreamingServerCallHandler.cs index 404822f98..da49752c9 100644 --- a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerStreamingServerCallHandler.cs +++ b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/ServerStreamingServerCallHandler.cs @@ -23,7 +23,7 @@ namespace Grpc.AspNetCore.Server.Internal.CallHandlers; -internal class ServerStreamingServerCallHandler<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerCallHandlerBase +internal sealed 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 499dc6491..f0d3047cd 100644 --- a/src/Grpc.AspNetCore.Server/Internal/CallHandlers/UnaryServerCallHandler.cs +++ b/src/Grpc.AspNetCore.Server/Internal/CallHandlers/UnaryServerCallHandler.cs @@ -24,7 +24,7 @@ namespace Grpc.AspNetCore.Server.Internal.CallHandlers; -internal class UnaryServerCallHandler<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService, TRequest, TResponse> : ServerCallHandlerBase +internal sealed 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/GrpcMarkerService.cs b/src/Grpc.AspNetCore.Server/Internal/GrpcMarkerService.cs index 0b75f7e7f..635b74ac4 100644 --- a/src/Grpc.AspNetCore.Server/Internal/GrpcMarkerService.cs +++ b/src/Grpc.AspNetCore.Server/Internal/GrpcMarkerService.cs @@ -24,6 +24,6 @@ namespace Grpc.AspNetCore.Server.Internal; /// A marker class used to determine if all the required gRPC services were added /// to the . /// -internal class GrpcMarkerService +internal sealed class GrpcMarkerService { } diff --git a/src/Grpc.AspNetCore.Server/Internal/GrpcServerBuilder.cs b/src/Grpc.AspNetCore.Server/Internal/GrpcServerBuilder.cs index 465c83b05..1704becc7 100644 --- a/src/Grpc.AspNetCore.Server/Internal/GrpcServerBuilder.cs +++ b/src/Grpc.AspNetCore.Server/Internal/GrpcServerBuilder.cs @@ -20,7 +20,7 @@ namespace Grpc.AspNetCore.Server.Internal; -internal class GrpcServerBuilder : IGrpcServerBuilder +internal sealed class GrpcServerBuilder : IGrpcServerBuilder { public IServiceCollection Services { get; } diff --git a/src/Grpc.AspNetCore.Server/Internal/GrpcServiceOptionsSetup.cs b/src/Grpc.AspNetCore.Server/Internal/GrpcServiceOptionsSetup.cs index f2fad234e..f6a9193af 100644 --- a/src/Grpc.AspNetCore.Server/Internal/GrpcServiceOptionsSetup.cs +++ b/src/Grpc.AspNetCore.Server/Internal/GrpcServiceOptionsSetup.cs @@ -22,7 +22,7 @@ namespace Grpc.AspNetCore.Server.Internal; -internal class GrpcServiceOptionsSetup : IConfigureOptions +internal sealed class GrpcServiceOptionsSetup : IConfigureOptions { // Default to no send limit and 4mb receive limit. // Matches the gRPC C impl defaults @@ -45,7 +45,7 @@ public void Configure(GrpcServiceOptions options) } } -internal class GrpcServiceOptionsSetup : IConfigureOptions> where TService : class +internal sealed class GrpcServiceOptionsSetup : IConfigureOptions> where TService : class { private readonly GrpcServiceOptions _options; diff --git a/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamReader.cs b/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamReader.cs index 528aeed87..169a460d5 100644 --- a/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamReader.cs +++ b/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamReader.cs @@ -26,7 +26,7 @@ namespace Grpc.AspNetCore.Server.Internal; [DebuggerDisplay("{DebuggerToString(),nq}")] [DebuggerTypeProxy(typeof(HttpContextStreamReader<>.HttpContextStreamReaderDebugView))] -internal class HttpContextStreamReader : IAsyncStreamReader where TRequest : class +internal sealed class HttpContextStreamReader : IAsyncStreamReader where TRequest : class { private readonly HttpContextServerCallContext _serverCallContext; private readonly Func _deserializer; diff --git a/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamWriter.cs b/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamWriter.cs index 8a96d9fa1..d69b8e7e6 100644 --- a/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamWriter.cs +++ b/src/Grpc.AspNetCore.Server/Internal/HttpContextStreamWriter.cs @@ -26,7 +26,7 @@ namespace Grpc.AspNetCore.Server.Internal; [DebuggerDisplay("{DebuggerToString(),nq}")] [DebuggerTypeProxy(typeof(HttpContextStreamWriter<>.HttpContextStreamWriterDebugView))] -internal class HttpContextStreamWriter : IServerStreamWriter +internal sealed class HttpContextStreamWriter : IServerStreamWriter where TResponse : class { private readonly HttpContextServerCallContext _context; diff --git a/src/Grpc.AspNetCore.Server/Internal/ReadOnlySequenceStream.cs b/src/Grpc.AspNetCore.Server/Internal/ReadOnlySequenceStream.cs index bd196e9f7..36f16774a 100644 --- a/src/Grpc.AspNetCore.Server/Internal/ReadOnlySequenceStream.cs +++ b/src/Grpc.AspNetCore.Server/Internal/ReadOnlySequenceStream.cs @@ -21,7 +21,7 @@ namespace Grpc.AspNetCore.Server.Internal; // Potentially remove in the future when https://github.com/dotnet/corefx/issues/31804 is implemented -internal class ReadOnlySequenceStream : Stream +internal sealed class ReadOnlySequenceStream : Stream { private static readonly Task TaskOfZero = Task.FromResult(0); diff --git a/src/Grpc.AspNetCore.Server/Internal/ServerCallHandlerFactory.cs b/src/Grpc.AspNetCore.Server/Internal/ServerCallHandlerFactory.cs index 95d545942..7da6ff722 100644 --- a/src/Grpc.AspNetCore.Server/Internal/ServerCallHandlerFactory.cs +++ b/src/Grpc.AspNetCore.Server/Internal/ServerCallHandlerFactory.cs @@ -31,7 +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<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> where TService : class +internal sealed 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/Internal/SystemClock.cs b/src/Grpc.AspNetCore.Server/Internal/SystemClock.cs index cfa40177b..89c4db069 100644 --- a/src/Grpc.AspNetCore.Server/Internal/SystemClock.cs +++ b/src/Grpc.AspNetCore.Server/Internal/SystemClock.cs @@ -18,7 +18,7 @@ namespace Grpc.AspNetCore.Server.Internal; -internal class SystemClock : ISystemClock +internal sealed class SystemClock : ISystemClock { public static readonly SystemClock Instance = new SystemClock(); diff --git a/src/Grpc.AspNetCore.Server/Model/Internal/BinderServiceModelProvider.cs b/src/Grpc.AspNetCore.Server/Model/Internal/BinderServiceModelProvider.cs index 101ee27e6..537b8a35b 100644 --- a/src/Grpc.AspNetCore.Server/Model/Internal/BinderServiceModelProvider.cs +++ b/src/Grpc.AspNetCore.Server/Model/Internal/BinderServiceModelProvider.cs @@ -24,7 +24,7 @@ namespace Grpc.AspNetCore.Server.Model.Internal; -internal class BinderServiceMethodProvider<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> : IServiceMethodProvider where TService : class +internal sealed class BinderServiceMethodProvider<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> : IServiceMethodProvider where TService : class { private readonly ILogger> _logger; diff --git a/src/Grpc.AspNetCore.Server/Model/Internal/MethodModel.cs b/src/Grpc.AspNetCore.Server/Model/Internal/MethodModel.cs index 3b82d96d2..c030a4cd4 100644 --- a/src/Grpc.AspNetCore.Server/Model/Internal/MethodModel.cs +++ b/src/Grpc.AspNetCore.Server/Model/Internal/MethodModel.cs @@ -22,7 +22,7 @@ namespace Grpc.AspNetCore.Server.Model.Internal; -internal class MethodModel +internal sealed class MethodModel { public MethodModel(IMethod method, RoutePattern pattern, IList metadata, RequestDelegate requestDelegate) { diff --git a/src/Grpc.AspNetCore.Server/Model/Internal/ProviderServiceBinder.cs b/src/Grpc.AspNetCore.Server/Model/Internal/ProviderServiceBinder.cs index 84be01989..eeaae23c6 100644 --- a/src/Grpc.AspNetCore.Server/Model/Internal/ProviderServiceBinder.cs +++ b/src/Grpc.AspNetCore.Server/Model/Internal/ProviderServiceBinder.cs @@ -24,7 +24,7 @@ namespace Grpc.AspNetCore.Server.Model.Internal; -internal class ProviderServiceBinder<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> : ServiceBinderBase where TService : class +internal sealed 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/ServiceMethodsRegistry.cs b/src/Grpc.AspNetCore.Server/Model/Internal/ServiceMethodsRegistry.cs index 5c2cf7882..0d1df6e45 100644 --- a/src/Grpc.AspNetCore.Server/Model/Internal/ServiceMethodsRegistry.cs +++ b/src/Grpc.AspNetCore.Server/Model/Internal/ServiceMethodsRegistry.cs @@ -21,7 +21,7 @@ namespace Grpc.AspNetCore.Server.Model.Internal; /// /// A registry of all the service methods in the application. /// -internal class ServiceMethodsRegistry +internal sealed class ServiceMethodsRegistry { public List Methods { get; } = new List(); } diff --git a/src/Grpc.AspNetCore.Server/Model/Internal/ServiceRouteBuilder.cs b/src/Grpc.AspNetCore.Server/Model/Internal/ServiceRouteBuilder.cs index dc3613ffa..b30d28a39 100644 --- a/src/Grpc.AspNetCore.Server/Model/Internal/ServiceRouteBuilder.cs +++ b/src/Grpc.AspNetCore.Server/Model/Internal/ServiceRouteBuilder.cs @@ -27,7 +27,7 @@ namespace Grpc.AspNetCore.Server.Model.Internal; -internal class ServiceRouteBuilder<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> where TService : class +internal sealed class ServiceRouteBuilder<[DynamicallyAccessedMembers(GrpcProtocolConstants.ServiceAccessibility)] TService> where TService : class { private readonly IEnumerable> _serviceMethodProviders; private readonly ServerCallHandlerFactory _serverCallHandlerFactory; diff --git a/src/Grpc.AspNetCore.Web/Internal/Base64PipeReader.cs b/src/Grpc.AspNetCore.Web/Internal/Base64PipeReader.cs index 668adeb88..ff5dabbb1 100644 --- a/src/Grpc.AspNetCore.Web/Internal/Base64PipeReader.cs +++ b/src/Grpc.AspNetCore.Web/Internal/Base64PipeReader.cs @@ -25,7 +25,7 @@ namespace Grpc.AspNetCore.Web.Internal; /// /// Reads and decodes base64 encoded bytes from the inner reader. /// -internal class Base64PipeReader : PipeReader +internal sealed class Base64PipeReader : PipeReader { private readonly PipeReader _inner; private ReadOnlySequence _currentDecodedBuffer; diff --git a/src/Grpc.AspNetCore.Web/Internal/Base64PipeWriter.cs b/src/Grpc.AspNetCore.Web/Internal/Base64PipeWriter.cs index 22185a23b..b50c70d26 100644 --- a/src/Grpc.AspNetCore.Web/Internal/Base64PipeWriter.cs +++ b/src/Grpc.AspNetCore.Web/Internal/Base64PipeWriter.cs @@ -25,7 +25,7 @@ namespace Grpc.AspNetCore.Web.Internal; /// /// Writes bytes as base64 encoded to the inner writer. /// -internal class Base64PipeWriter : PipeWriter +internal sealed class Base64PipeWriter : PipeWriter { private readonly PipeWriter _inner; // We have to write original data to buffer. GetSpan/GetMemory isn't guaranteed to return the @@ -187,4 +187,4 @@ private void WriteRemainder() _remainder = 0; } } -} \ No newline at end of file +} diff --git a/src/Grpc.AspNetCore.Web/Internal/GrpcWebFeature.cs b/src/Grpc.AspNetCore.Web/Internal/GrpcWebFeature.cs index 23738e426..adfda938d 100644 --- a/src/Grpc.AspNetCore.Web/Internal/GrpcWebFeature.cs +++ b/src/Grpc.AspNetCore.Web/Internal/GrpcWebFeature.cs @@ -22,7 +22,7 @@ namespace Grpc.AspNetCore.Web.Internal; -internal class GrpcWebFeature : +internal sealed class GrpcWebFeature : IRequestBodyPipeFeature, IHttpResponseBodyFeature, IHttpResponseTrailersFeature, diff --git a/src/Grpc.AspNetCore.Web/Internal/MemorySegment.cs b/src/Grpc.AspNetCore.Web/Internal/MemorySegment.cs index 7a534f1e3..63b1eedd1 100644 --- a/src/Grpc.AspNetCore.Web/Internal/MemorySegment.cs +++ b/src/Grpc.AspNetCore.Web/Internal/MemorySegment.cs @@ -20,7 +20,7 @@ namespace Grpc.AspNetCore.Web.Internal; -internal class MemorySegment : ReadOnlySequenceSegment +internal sealed class MemorySegment : ReadOnlySequenceSegment { public MemorySegment(ReadOnlyMemory memory) { diff --git a/src/Grpc.Core.Api/CallCredentials.cs b/src/Grpc.Core.Api/CallCredentials.cs index 086ecd8ca..144989d5c 100644 --- a/src/Grpc.Core.Api/CallCredentials.cs +++ b/src/Grpc.Core.Api/CallCredentials.cs @@ -53,7 +53,7 @@ public static CallCredentials FromInterceptor(AsyncAuthInterceptor interceptor) /// public abstract void InternalPopulateConfiguration(CallCredentialsConfiguratorBase configurator, object? state); - private class CompositeCallCredentials : CallCredentials + private sealed class CompositeCallCredentials : CallCredentials { readonly IReadOnlyList credentials; @@ -69,7 +69,7 @@ public override void InternalPopulateConfiguration(CallCredentialsConfiguratorBa } } - private class AsyncAuthInterceptorCredentials : CallCredentials + private sealed class AsyncAuthInterceptorCredentials : CallCredentials { readonly AsyncAuthInterceptor interceptor; diff --git a/src/Grpc.Core.Api/ClientBase.cs b/src/Grpc.Core.Api/ClientBase.cs index 7379959b9..bd01586a0 100644 --- a/src/Grpc.Core.Api/ClientBase.cs +++ b/src/Grpc.Core.Api/ClientBase.cs @@ -175,12 +175,12 @@ public ClientBaseDebugType(ClientBase client) /// /// Represents configuration of ClientBase. The class itself is visible to /// subclasses, but contents are marked as internal to make the instances opaque. - /// The verbose name of this class was chosen to make name clash in generated code + /// The verbose name of this class was chosen to make name clash in generated code /// less likely. /// protected internal class ClientBaseConfiguration { - private class ClientBaseConfigurationInterceptor : Interceptor + private sealed class ClientBaseConfigurationInterceptor : Interceptor { readonly Func interceptor; diff --git a/src/Grpc.Core.Api/Interceptors/CallInvokerExtensions.cs b/src/Grpc.Core.Api/Interceptors/CallInvokerExtensions.cs index 81a27943a..3aedecfa6 100644 --- a/src/Grpc.Core.Api/Interceptors/CallInvokerExtensions.cs +++ b/src/Grpc.Core.Api/Interceptors/CallInvokerExtensions.cs @@ -94,7 +94,7 @@ public static CallInvoker Intercept(this CallInvoker invoker, Func interceptor; diff --git a/src/Grpc.Core.Api/Interceptors/InterceptingCallInvoker.cs b/src/Grpc.Core.Api/Interceptors/InterceptingCallInvoker.cs index d1e39a77d..902a98010 100644 --- a/src/Grpc.Core.Api/Interceptors/InterceptingCallInvoker.cs +++ b/src/Grpc.Core.Api/Interceptors/InterceptingCallInvoker.cs @@ -16,7 +16,6 @@ #endregion -using System; using System.Diagnostics; using Grpc.Core.Utils; @@ -27,7 +26,7 @@ namespace Grpc.Core.Interceptors; /// intercept calls through a given interceptor. /// [DebuggerDisplay("{invoker}")] -internal class InterceptingCallInvoker : CallInvoker +internal sealed class InterceptingCallInvoker : CallInvoker { readonly CallInvoker invoker; readonly Interceptor interceptor; diff --git a/src/Grpc.Core.Api/Internal/UnimplementedCallInvoker.cs b/src/Grpc.Core.Api/Internal/UnimplementedCallInvoker.cs index 7fadcd255..bebf7694d 100644 --- a/src/Grpc.Core.Api/Internal/UnimplementedCallInvoker.cs +++ b/src/Grpc.Core.Api/Internal/UnimplementedCallInvoker.cs @@ -17,16 +17,13 @@ #endregion using System; -using System.Threading.Tasks; -using Grpc.Core; -using Grpc.Core.Utils; namespace Grpc.Core.Internal; /// /// Call invoker that throws NotImplementedException for all requests. /// -internal class UnimplementedCallInvoker : CallInvoker +internal sealed class UnimplementedCallInvoker : CallInvoker { public UnimplementedCallInvoker() { diff --git a/src/Grpc.Net.Client.Web/Internal/Base64RequestStream.cs b/src/Grpc.Net.Client.Web/Internal/Base64RequestStream.cs index cd73c42b5..e9c1c2499 100644 --- a/src/Grpc.Net.Client.Web/Internal/Base64RequestStream.cs +++ b/src/Grpc.Net.Client.Web/Internal/Base64RequestStream.cs @@ -21,7 +21,7 @@ namespace Grpc.Net.Client.Web.Internal; -internal class Base64RequestStream : Stream +internal sealed class Base64RequestStream : Stream { private readonly Stream _inner; private byte[]? _buffer; diff --git a/src/Grpc.Net.Client.Web/Internal/Base64ResponseStream.cs b/src/Grpc.Net.Client.Web/Internal/Base64ResponseStream.cs index ec37ae87a..18bd6eec2 100644 --- a/src/Grpc.Net.Client.Web/Internal/Base64ResponseStream.cs +++ b/src/Grpc.Net.Client.Web/Internal/Base64ResponseStream.cs @@ -22,7 +22,7 @@ namespace Grpc.Net.Client.Web.Internal; -internal class Base64ResponseStream : Stream +internal sealed class Base64ResponseStream : Stream { private readonly Stream _inner; diff --git a/src/Grpc.Net.Client.Web/Internal/GrpcWebRequestContent.cs b/src/Grpc.Net.Client.Web/Internal/GrpcWebRequestContent.cs index 4a9586223..4309bf34c 100644 --- a/src/Grpc.Net.Client.Web/Internal/GrpcWebRequestContent.cs +++ b/src/Grpc.Net.Client.Web/Internal/GrpcWebRequestContent.cs @@ -20,7 +20,7 @@ namespace Grpc.Net.Client.Web.Internal; -internal class GrpcWebRequestContent : HttpContent +internal sealed class GrpcWebRequestContent : HttpContent { private readonly HttpContent _inner; private readonly GrpcWebMode _mode; diff --git a/src/Grpc.Net.Client.Web/Internal/GrpcWebResponseContent.cs b/src/Grpc.Net.Client.Web/Internal/GrpcWebResponseContent.cs index 8df348fe6..f7105942e 100644 --- a/src/Grpc.Net.Client.Web/Internal/GrpcWebResponseContent.cs +++ b/src/Grpc.Net.Client.Web/Internal/GrpcWebResponseContent.cs @@ -21,7 +21,7 @@ namespace Grpc.Net.Client.Web.Internal; -internal class GrpcWebResponseContent : HttpContent +internal sealed class GrpcWebResponseContent : HttpContent { private readonly HttpContent _inner; private readonly GrpcWebMode _mode; diff --git a/src/Grpc.Net.Client.Web/Internal/GrpcWebResponseStream.cs b/src/Grpc.Net.Client.Web/Internal/GrpcWebResponseStream.cs index 3f29028d5..7e2cc7054 100644 --- a/src/Grpc.Net.Client.Web/Internal/GrpcWebResponseStream.cs +++ b/src/Grpc.Net.Client.Web/Internal/GrpcWebResponseStream.cs @@ -29,7 +29,7 @@ namespace Grpc.Net.Client.Web.Internal; /// for trailers. When the trailers message is encountered then they are parsed as HTTP/1.1 trailers and /// added to the HttpResponseMessage.TrailingHeaders. /// -internal class GrpcWebResponseStream : Stream +internal sealed class GrpcWebResponseStream : Stream { private const int HeaderLength = 5; diff --git a/src/Grpc.Net.Client.Web/Internal/OperatingSystem.cs b/src/Grpc.Net.Client.Web/Internal/OperatingSystem.cs index 0c15c19bb..759cdc838 100644 --- a/src/Grpc.Net.Client.Web/Internal/OperatingSystem.cs +++ b/src/Grpc.Net.Client.Web/Internal/OperatingSystem.cs @@ -25,7 +25,7 @@ internal interface IOperatingSystem bool IsBrowser { get; } } -internal class OperatingSystem : IOperatingSystem +internal sealed class OperatingSystem : IOperatingSystem { public static readonly OperatingSystem Instance = new OperatingSystem(); diff --git a/src/Grpc.Net.Client/Balancer/Internal/BalancerAddressEqualityComparer.cs b/src/Grpc.Net.Client/Balancer/Internal/BalancerAddressEqualityComparer.cs index 60c62bf59..5f852a416 100644 --- a/src/Grpc.Net.Client/Balancer/Internal/BalancerAddressEqualityComparer.cs +++ b/src/Grpc.Net.Client/Balancer/Internal/BalancerAddressEqualityComparer.cs @@ -21,7 +21,7 @@ namespace Grpc.Net.Client.Balancer.Internal; -internal class BalancerAddressEqualityComparer : IEqualityComparer +internal sealed class BalancerAddressEqualityComparer : IEqualityComparer { internal static readonly BalancerAddressEqualityComparer Instance = new BalancerAddressEqualityComparer(); diff --git a/src/Grpc.Net.Client/Balancer/Internal/BalancerHttpHandler.cs b/src/Grpc.Net.Client/Balancer/Internal/BalancerHttpHandler.cs index 37bc3c7e9..8b0953e8e 100644 --- a/src/Grpc.Net.Client/Balancer/Internal/BalancerHttpHandler.cs +++ b/src/Grpc.Net.Client/Balancer/Internal/BalancerHttpHandler.cs @@ -17,19 +17,14 @@ #endregion #if SUPPORT_LOAD_BALANCING -using System; using System.Diagnostics; -using System.IO; using System.Net; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; using Grpc.Shared; using Microsoft.Extensions.Logging; namespace Grpc.Net.Client.Balancer.Internal; -internal partial class BalancerHttpHandler : DelegatingHandler +internal sealed partial class BalancerHttpHandler : DelegatingHandler { private static readonly object SetupLock = new object(); @@ -178,7 +173,7 @@ internal static partial class Log public static partial void SendingRequest(ILogger logger, Uri requestUri); [LoggerMessage(Level = LogLevel.Trace, EventId = 2, EventName = "StartingConnectCallback", Message = "Starting connect callback for {Endpoint}.")] - private static partial void StartingConnectCallback(ILogger logger, string endpoint); + private static partial void StartingConnectCallback(ILogger logger, string endpoint); public static void StartingConnectCallback(ILogger logger, DnsEndPoint endpoint) { diff --git a/src/Grpc.Net.Client/Balancer/Internal/ErrorPicker.cs b/src/Grpc.Net.Client/Balancer/Internal/ErrorPicker.cs index b96865943..e9eb4fcf0 100644 --- a/src/Grpc.Net.Client/Balancer/Internal/ErrorPicker.cs +++ b/src/Grpc.Net.Client/Balancer/Internal/ErrorPicker.cs @@ -17,13 +17,12 @@ #endregion #if SUPPORT_LOAD_BALANCING -using System; using System.Diagnostics; using Grpc.Core; namespace Grpc.Net.Client.Balancer.Internal; -internal class ErrorPicker : SubchannelPicker +internal sealed class ErrorPicker : SubchannelPicker { private readonly Status _status; diff --git a/src/Grpc.Net.Client/Balancer/Internal/PassiveSubchannelTransport.cs b/src/Grpc.Net.Client/Balancer/Internal/PassiveSubchannelTransport.cs index a4ea4093c..83217f6c4 100644 --- a/src/Grpc.Net.Client/Balancer/Internal/PassiveSubchannelTransport.cs +++ b/src/Grpc.Net.Client/Balancer/Internal/PassiveSubchannelTransport.cs @@ -17,12 +17,8 @@ #endregion #if SUPPORT_LOAD_BALANCING -using System; using System.Diagnostics; -using System.IO; using System.Net; -using System.Threading; -using System.Threading.Tasks; using Grpc.Core; namespace Grpc.Net.Client.Balancer.Internal; @@ -32,7 +28,7 @@ namespace Grpc.Net.Client.Balancer.Internal; /// This transport will only be used when there is one address. /// It isn't able to correctly determine connectivity state. /// -internal class PassiveSubchannelTransport : ISubchannelTransport, IDisposable +internal sealed class PassiveSubchannelTransport : ISubchannelTransport, IDisposable { private readonly Subchannel _subchannel; private DnsEndPoint? _currentEndPoint; diff --git a/src/Grpc.Net.Client/Balancer/Internal/SocketConnectivitySubchannelTransport.cs b/src/Grpc.Net.Client/Balancer/Internal/SocketConnectivitySubchannelTransport.cs index f1f3ffab3..41656ae64 100644 --- a/src/Grpc.Net.Client/Balancer/Internal/SocketConnectivitySubchannelTransport.cs +++ b/src/Grpc.Net.Client/Balancer/Internal/SocketConnectivitySubchannelTransport.cs @@ -28,7 +28,7 @@ namespace Grpc.Net.Client.Balancer.Internal; /// /// Transport that makes it possible to monitor connectivity state while using HttpClient. -/// +/// /// Features: /// 1. When a connection is requested the transport creates a Socket and connects to the server. /// The socket is used with the first stream created by SocketsHttpHandler.ConnectCallback. @@ -39,7 +39,7 @@ namespace Grpc.Net.Client.Balancer.Internal; /// 2. Transport supports multiple addresses. When connecting it will iterate through the addresses, /// attempting to connect to each one. /// -internal class SocketConnectivitySubchannelTransport : ISubchannelTransport, IDisposable +internal sealed class SocketConnectivitySubchannelTransport : ISubchannelTransport, IDisposable { private const int MaximumInitialSocketDataSize = 1024 * 16; internal static readonly TimeSpan SocketPingInterval = TimeSpan.FromSeconds(5); diff --git a/src/Grpc.Net.Client/Balancer/PickFirstBalancer.cs b/src/Grpc.Net.Client/Balancer/PickFirstBalancer.cs index 88f4cfead..bc1f5ad90 100644 --- a/src/Grpc.Net.Client/Balancer/PickFirstBalancer.cs +++ b/src/Grpc.Net.Client/Balancer/PickFirstBalancer.cs @@ -17,8 +17,6 @@ #endregion #if SUPPORT_LOAD_BALANCING -using System; -using System.Collections.Generic; using Grpc.Core; using Grpc.Net.Client.Balancer.Internal; using Grpc.Net.Client.Configuration; @@ -187,7 +185,7 @@ public override PickResult Pick(PickContext context) } } -internal class RequestConnectionPicker : PickFirstPicker +internal sealed class RequestConnectionPicker : PickFirstPicker { public RequestConnectionPicker(Subchannel subchannel) : base(subchannel) { diff --git a/src/Grpc.Net.Client/Internal/GrpcCallScope.cs b/src/Grpc.Net.Client/Internal/GrpcCallScope.cs index afc3d79c7..abc9b4b02 100644 --- a/src/Grpc.Net.Client/Internal/GrpcCallScope.cs +++ b/src/Grpc.Net.Client/Internal/GrpcCallScope.cs @@ -21,7 +21,7 @@ namespace Grpc.Net.Client.Internal; -internal class GrpcCallScope : IReadOnlyList> +internal sealed class GrpcCallScope : IReadOnlyList> { private const string GrpcMethodTypeKey = "GrpcMethodType"; private const string GrpcUriKey = "GrpcUri"; diff --git a/src/Grpc.Net.Client/Internal/GrpcMethodInfo.cs b/src/Grpc.Net.Client/Internal/GrpcMethodInfo.cs index 5f357730b..fad5e0b18 100644 --- a/src/Grpc.Net.Client/Internal/GrpcMethodInfo.cs +++ b/src/Grpc.Net.Client/Internal/GrpcMethodInfo.cs @@ -24,7 +24,7 @@ namespace Grpc.Net.Client.Internal; /// /// Cached log scope and URI for a gRPC . /// -internal class GrpcMethodInfo +internal sealed class GrpcMethodInfo { public GrpcMethodInfo(GrpcCallScope logScope, Uri callUri, MethodConfig? methodConfig) { @@ -116,13 +116,13 @@ internal static HedgingPolicyInfo CreateHedgingPolicy(HedgingPolicy h) public MethodConfigInfo? MethodConfig { get; } } -internal class MethodConfigInfo +internal sealed class MethodConfigInfo { public RetryPolicyInfo? RetryPolicy { get; set; } public HedgingPolicyInfo? HedgingPolicy { get; set; } } -internal class RetryPolicyInfo +internal sealed class RetryPolicyInfo { public int MaxAttempts { get; init; } public TimeSpan InitialBackoff { get; init; } @@ -131,7 +131,7 @@ internal class RetryPolicyInfo public List RetryableStatusCodes { get; init; } = default!; } -internal class HedgingPolicyInfo +internal sealed class HedgingPolicyInfo { public int MaxAttempts { get; set; } public TimeSpan HedgingDelay { get; set; } diff --git a/src/Grpc.Net.Client/Internal/Http/PushStreamContent.cs b/src/Grpc.Net.Client/Internal/Http/PushStreamContent.cs index 13ae19a3f..2e1e2407d 100644 --- a/src/Grpc.Net.Client/Internal/Http/PushStreamContent.cs +++ b/src/Grpc.Net.Client/Internal/Http/PushStreamContent.cs @@ -20,7 +20,7 @@ namespace Grpc.Net.Client.Internal.Http; -internal class PushStreamContent : HttpContent +internal sealed class PushStreamContent : HttpContent where TRequest : class where TResponse : class { diff --git a/src/Grpc.Net.Client/Internal/Http/PushUnaryContent.cs b/src/Grpc.Net.Client/Internal/Http/PushUnaryContent.cs index c31a72251..a1b232fd5 100644 --- a/src/Grpc.Net.Client/Internal/Http/PushUnaryContent.cs +++ b/src/Grpc.Net.Client/Internal/Http/PushUnaryContent.cs @@ -22,7 +22,7 @@ namespace Grpc.Net.Client.Internal; // TODO: Still need generic args? -internal class PushUnaryContent : HttpContent +internal sealed class PushUnaryContent : HttpContent where TRequest : class where TResponse : class { diff --git a/src/Grpc.Net.Client/Internal/Http/WinHttpUnaryContent.cs b/src/Grpc.Net.Client/Internal/Http/WinHttpUnaryContent.cs index 44e1c374d..39e946a85 100644 --- a/src/Grpc.Net.Client/Internal/Http/WinHttpUnaryContent.cs +++ b/src/Grpc.Net.Client/Internal/Http/WinHttpUnaryContent.cs @@ -27,7 +27,7 @@ namespace Grpc.Net.Client.Internal.Http; /// The payload is then written directly to the request using specialized context /// and serializer method. /// -internal class WinHttpUnaryContent : HttpContent +internal sealed class WinHttpUnaryContent : HttpContent where TRequest : class where TResponse : class { diff --git a/src/Grpc.Net.Client/Internal/HttpContentClientStreamReader.cs b/src/Grpc.Net.Client/Internal/HttpContentClientStreamReader.cs index 7ec3a1534..907604752 100644 --- a/src/Grpc.Net.Client/Internal/HttpContentClientStreamReader.cs +++ b/src/Grpc.Net.Client/Internal/HttpContentClientStreamReader.cs @@ -27,7 +27,7 @@ namespace Grpc.Net.Client.Internal; [DebuggerDisplay("{DebuggerToString(),nq}")] [DebuggerTypeProxy(typeof(HttpContentClientStreamReader<,>.HttpContentClientStreamReaderDebugView))] -internal class HttpContentClientStreamReader : IAsyncStreamReader +internal sealed class HttpContentClientStreamReader : IAsyncStreamReader where TRequest : class where TResponse : class { diff --git a/src/Grpc.Net.Client/Internal/HttpContentClientStreamWriter.cs b/src/Grpc.Net.Client/Internal/HttpContentClientStreamWriter.cs index 028658e18..83666f9ba 100644 --- a/src/Grpc.Net.Client/Internal/HttpContentClientStreamWriter.cs +++ b/src/Grpc.Net.Client/Internal/HttpContentClientStreamWriter.cs @@ -26,7 +26,7 @@ namespace Grpc.Net.Client.Internal; [DebuggerDisplay("{DebuggerToString(),nq}")] [DebuggerTypeProxy(typeof(HttpContentClientStreamWriter<,>.HttpContentClientStreamWriterDebugView))] -internal class HttpContentClientStreamWriter : ClientStreamWriterBase +internal sealed class HttpContentClientStreamWriter : ClientStreamWriterBase where TRequest : class where TResponse : class { diff --git a/src/Grpc.Net.Client/Internal/Retry/ChannelRetryThrottling.cs b/src/Grpc.Net.Client/Internal/Retry/ChannelRetryThrottling.cs index 17c52c84a..874f843eb 100644 --- a/src/Grpc.Net.Client/Internal/Retry/ChannelRetryThrottling.cs +++ b/src/Grpc.Net.Client/Internal/Retry/ChannelRetryThrottling.cs @@ -21,7 +21,7 @@ namespace Grpc.Net.Client.Internal.Retry; -internal partial class ChannelRetryThrottling +internal sealed partial class ChannelRetryThrottling { private readonly object _lock = new object(); private readonly double _tokenRatio; diff --git a/src/Grpc.Net.Client/Internal/Retry/RetryCallBaseClientStreamReader.cs b/src/Grpc.Net.Client/Internal/Retry/RetryCallBaseClientStreamReader.cs index 5c68c18cb..da41c5d82 100644 --- a/src/Grpc.Net.Client/Internal/Retry/RetryCallBaseClientStreamReader.cs +++ b/src/Grpc.Net.Client/Internal/Retry/RetryCallBaseClientStreamReader.cs @@ -24,7 +24,7 @@ namespace Grpc.Net.Client.Internal.Retry; [DebuggerDisplay("{DebuggerToString(),nq}")] [DebuggerTypeProxy(typeof(RetryCallBaseClientStreamReader<,>.RetryCallBaseClientStreamReaderDebugView))] -internal class RetryCallBaseClientStreamReader : IAsyncStreamReader +internal sealed class RetryCallBaseClientStreamReader : IAsyncStreamReader where TRequest : class where TResponse : class { diff --git a/src/Grpc.Net.Client/Internal/Retry/RetryCallBaseClientStreamWriter.cs b/src/Grpc.Net.Client/Internal/Retry/RetryCallBaseClientStreamWriter.cs index 0ceffe746..9d5857df2 100644 --- a/src/Grpc.Net.Client/Internal/Retry/RetryCallBaseClientStreamWriter.cs +++ b/src/Grpc.Net.Client/Internal/Retry/RetryCallBaseClientStreamWriter.cs @@ -24,7 +24,7 @@ namespace Grpc.Net.Client.Internal.Retry; [DebuggerDisplay("{DebuggerToString(),nq}")] [DebuggerTypeProxy(typeof(RetryCallBaseClientStreamWriter<,>.RetryCallBaseClientStreamWriterDebugView))] -internal class RetryCallBaseClientStreamWriter : ClientStreamWriterBase +internal sealed class RetryCallBaseClientStreamWriter : ClientStreamWriterBase where TRequest : class where TResponse : class { diff --git a/src/Shared/Server/InterceptorPipelineBuilder.cs b/src/Shared/Server/InterceptorPipelineBuilder.cs index df1da7297..71e5e9a1d 100644 --- a/src/Shared/Server/InterceptorPipelineBuilder.cs +++ b/src/Shared/Server/InterceptorPipelineBuilder.cs @@ -22,7 +22,7 @@ namespace Grpc.Shared.Server; -internal class InterceptorPipelineBuilder +internal sealed class InterceptorPipelineBuilder where TRequest : class where TResponse : class { @@ -159,4 +159,4 @@ private static GrpcActivatorHandle CreateInterceptor(InterceptorReg return interceptorHandle; } -} \ No newline at end of file +} diff --git a/src/Shared/TrailingHeadersHelpers.cs b/src/Shared/TrailingHeadersHelpers.cs index 024a5b9b9..ce4d29518 100644 --- a/src/Shared/TrailingHeadersHelpers.cs +++ b/src/Shared/TrailingHeadersHelpers.cs @@ -51,7 +51,7 @@ public static void EnsureTrailingHeaders(this HttpResponseMessage responseMessag public static readonly string ResponseTrailersKey = "__ResponseTrailers"; - private class ResponseTrailers : HttpHeaders + private sealed class ResponseTrailers : HttpHeaders { public static readonly ResponseTrailers Empty = new ResponseTrailers(); } diff --git a/src/dotnet-grpc/Commands/AddFileCommand.cs b/src/dotnet-grpc/Commands/AddFileCommand.cs index 35302c143..dd6e79b48 100644 --- a/src/dotnet-grpc/Commands/AddFileCommand.cs +++ b/src/dotnet-grpc/Commands/AddFileCommand.cs @@ -16,17 +16,14 @@ #endregion -using System; using System.CommandLine; -using System.CommandLine.Invocation; using Grpc.Dotnet.Cli.Internal; using Grpc.Dotnet.Cli.Options; using Grpc.Dotnet.Cli.Properties; -using Microsoft.Build.Evaluation; namespace Grpc.Dotnet.Cli.Commands; -internal class AddFileCommand : CommandBase +internal sealed class AddFileCommand : CommandBase { public AddFileCommand(IConsole console, string? projectPath, HttpClient httpClient) : base(console, projectPath, httpClient) { } diff --git a/src/dotnet-grpc/Commands/AddUrlCommand.cs b/src/dotnet-grpc/Commands/AddUrlCommand.cs index fa8a52265..99e9b0ebf 100644 --- a/src/dotnet-grpc/Commands/AddUrlCommand.cs +++ b/src/dotnet-grpc/Commands/AddUrlCommand.cs @@ -17,14 +17,13 @@ #endregion using System.CommandLine; -using System.CommandLine.Invocation; using Grpc.Dotnet.Cli.Internal; using Grpc.Dotnet.Cli.Options; using Grpc.Dotnet.Cli.Properties; namespace Grpc.Dotnet.Cli.Commands; -internal class AddUrlCommand : CommandBase +internal sealed class AddUrlCommand : CommandBase { public AddUrlCommand(IConsole console, string? projectPath, HttpClient httpClient) : base(console, projectPath, httpClient) { } diff --git a/src/dotnet-grpc/Commands/ListCommand.cs b/src/dotnet-grpc/Commands/ListCommand.cs index 158510355..99056aec4 100644 --- a/src/dotnet-grpc/Commands/ListCommand.cs +++ b/src/dotnet-grpc/Commands/ListCommand.cs @@ -17,7 +17,6 @@ #endregion using System.CommandLine; -using System.CommandLine.Invocation; using System.CommandLine.Rendering; using System.CommandLine.Rendering.Views; using Grpc.Dotnet.Cli.Internal; @@ -27,7 +26,7 @@ namespace Grpc.Dotnet.Cli.Commands; -internal class ListCommand : CommandBase +internal sealed class ListCommand : CommandBase { public ListCommand(IConsole console, string? projectPath, HttpClient httpClient) : base(console, projectPath, httpClient) { } diff --git a/src/dotnet-grpc/Commands/RefreshCommand.cs b/src/dotnet-grpc/Commands/RefreshCommand.cs index 2069f1f15..be5522748 100644 --- a/src/dotnet-grpc/Commands/RefreshCommand.cs +++ b/src/dotnet-grpc/Commands/RefreshCommand.cs @@ -17,15 +17,13 @@ #endregion using System.CommandLine; -using System.CommandLine.Invocation; using Grpc.Dotnet.Cli.Internal; using Grpc.Dotnet.Cli.Options; using Grpc.Dotnet.Cli.Properties; -using Microsoft.Build.Evaluation; namespace Grpc.Dotnet.Cli.Commands; -internal class RefreshCommand : CommandBase +internal sealed class RefreshCommand : CommandBase { public RefreshCommand(IConsole console, string? projectPath, HttpClient httpClient) : base(console, projectPath, httpClient) { } diff --git a/src/dotnet-grpc/Commands/RemoveCommand.cs b/src/dotnet-grpc/Commands/RemoveCommand.cs index 1a956b352..3bfc7d11e 100644 --- a/src/dotnet-grpc/Commands/RemoveCommand.cs +++ b/src/dotnet-grpc/Commands/RemoveCommand.cs @@ -16,17 +16,14 @@ #endregion -using System; using System.CommandLine; -using System.CommandLine.Invocation; using Grpc.Dotnet.Cli.Internal; using Grpc.Dotnet.Cli.Options; using Grpc.Dotnet.Cli.Properties; -using Microsoft.Build.Evaluation; namespace Grpc.Dotnet.Cli.Commands; -internal class RemoveCommand : CommandBase +internal sealed class RemoveCommand : CommandBase { public RemoveCommand(IConsole console, string? projectPath, HttpClient httpClient) : base(console, projectPath, httpClient) { } diff --git a/src/dotnet-grpc/Internal/CLIToolException.cs b/src/dotnet-grpc/Internal/CLIToolException.cs index b9dbb71ec..92ac9945d 100644 --- a/src/dotnet-grpc/Internal/CLIToolException.cs +++ b/src/dotnet-grpc/Internal/CLIToolException.cs @@ -19,7 +19,7 @@ namespace Grpc.Dotnet.Cli.Internal; -internal class CLIToolException : Exception +internal sealed class CLIToolException : Exception { public CLIToolException(string message) : base(message) { } } diff --git a/src/dotnet-grpc/Internal/GrpcDependencyAttribute.cs b/src/dotnet-grpc/Internal/GrpcDependencyAttribute.cs index 7b1a69f63..08f0b311b 100644 --- a/src/dotnet-grpc/Internal/GrpcDependencyAttribute.cs +++ b/src/dotnet-grpc/Internal/GrpcDependencyAttribute.cs @@ -20,7 +20,7 @@ namespace Grpc.Dotnet.Cli.Internal; [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] -internal class GrpcDependencyAttribute : Attribute +internal sealed class GrpcDependencyAttribute : Attribute { public GrpcDependencyAttribute(string name, string version, string privateAssets, string applicableServices, string? applicableToWeb = null) {