From 1232f60ac2dfc46f314cbe35326d7508cbf5a4e9 Mon Sep 17 00:00:00 2001 From: Christopher Warrington Date: Thu, 21 Feb 2019 17:26:54 -0800 Subject: [PATCH] Make UserState non-virtual; add protected impl Makes the public UserState property non-virtual and adds a protected virtual UserStateCore that can be overridden. This follows the pattern of the other members. --- src/csharp/Grpc.Core.Api/ServerCallContext.cs | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/csharp/Grpc.Core.Api/ServerCallContext.cs b/src/csharp/Grpc.Core.Api/ServerCallContext.cs index 7cc03cb3a0b..8d7dbf544d6 100644 --- a/src/csharp/Grpc.Core.Api/ServerCallContext.cs +++ b/src/csharp/Grpc.Core.Api/ServerCallContext.cs @@ -120,18 +120,7 @@ namespace Grpc.Core /// Gets a dictionary that can be used by the various interceptors and handlers of this /// call to store arbitrary state. /// - public virtual IDictionary UserState - { - get - { - if (userState == null) - { - userState = new Dictionary(); - } - - return userState; - } - } + public IDictionary UserState => UserStateCore; /// Provides implementation of a non-virtual public member. protected abstract Task WriteResponseHeadersAsyncCore(Metadata responseHeaders); @@ -157,5 +146,18 @@ namespace Grpc.Core protected abstract WriteOptions WriteOptionsCore { get; set; } /// Provides implementation of a non-virtual public member. protected abstract AuthContext AuthContextCore { get; } + /// Provides implementation of a non-virtual public member. + protected virtual IDictionary UserStateCore + { + get + { + if (userState == null) + { + userState = new Dictionary(); + } + + return userState; + } + } } }