From b5e8438ecb4fa4605ffdc0f9f0228ae240cea917 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 26 Jul 2023 01:11:25 -0400 Subject: [PATCH] Lazily initialize TokenValidationParameters.InstancePropertyBag --- .../TokenValidationParameters.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.IdentityModel.Tokens/TokenValidationParameters.cs b/src/Microsoft.IdentityModel.Tokens/TokenValidationParameters.cs index cf40db0b45..c98a01afdd 100644 --- a/src/Microsoft.IdentityModel.Tokens/TokenValidationParameters.cs +++ b/src/Microsoft.IdentityModel.Tokens/TokenValidationParameters.cs @@ -189,6 +189,7 @@ public class TokenValidationParameters private TimeSpan _clockSkew = DefaultClockSkew; private string _nameClaimType = ClaimsIdentity.DefaultNameClaimType; private string _roleClaimType = ClaimsIdentity.DefaultRoleClaimType; + private Dictionary _instancePropertyBag; /// /// This is the default value of when creating a . @@ -483,7 +484,7 @@ public virtual ClaimsIdentity CreateClaimsIdentity(SecurityToken securityToken, /// Gets a that is unique to this instance. /// Calling will result in a new instance of this IDictionary. /// - public IDictionary InstancePropertyBag { get; } = new Dictionary(); + public IDictionary InstancePropertyBag => _instancePropertyBag ??= new Dictionary(); /// /// Gets a value indicating if was called to obtain this instance.