Skip to content

Commit c2b81c9

Browse files
stephentoubbrentschmaltz
authored andcommitted
Lazily initialize TokenValidationParameters.InstancePropertyBag (#2160)
1 parent 834e1f7 commit c2b81c9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Microsoft.IdentityModel.Tokens/TokenValidationParameters.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public class TokenValidationParameters
189189
private TimeSpan _clockSkew = DefaultClockSkew;
190190
private string _nameClaimType = ClaimsIdentity.DefaultNameClaimType;
191191
private string _roleClaimType = ClaimsIdentity.DefaultRoleClaimType;
192+
private Dictionary<string, object> _instancePropertyBag;
192193

193194
/// <summary>
194195
/// This is the default value of <see cref="ClaimsIdentity.AuthenticationType"/> when creating a <see cref="ClaimsIdentity"/>.
@@ -483,7 +484,7 @@ public virtual ClaimsIdentity CreateClaimsIdentity(SecurityToken securityToken,
483484
/// Gets a <see cref="IDictionary{String, Object}"/> that is unique to this instance.
484485
/// Calling <see cref="Clone"/> will result in a new instance of this IDictionary.
485486
/// </summary>
486-
public IDictionary<string, object> InstancePropertyBag { get; } = new Dictionary<string, object>();
487+
public IDictionary<string, object> InstancePropertyBag => _instancePropertyBag ??= new Dictionary<string, object>();
487488

488489
/// <summary>
489490
/// Gets a value indicating if <see cref="Clone"/> was called to obtain this instance.

0 commit comments

Comments
 (0)