However, if you are writing code to inspect the Claim and checking if there are any Properties, the only way to check is to allocate this Dictionary just to see that its Count == 0. For example, here is some code from the JWT handling code in Microsoft.IdentityModel.JsonWebTokens:
Background and motivation
System.Security.Claims.Claim
will lazy load itsProperties
dictionary:https://github.com/dotnet/runtime/blob/84b33395057737db3ea342a5151feb6b90c1b6f6/src/libraries/System.Security.Claims/src/System/Security/Claims/Claim.cs#L344
However, if you are writing code to inspect the
Claim
and checking if there are anyProperties
, the only way to check is to allocate this Dictionary just to see that itsCount == 0
. For example, here is some code from the JWT handling code in Microsoft.IdentityModel.JsonWebTokens:Just doing that first check allocates the Dictionary on the
Claim
and then basically just throws it away (since the Claim has no Properties).API Proposal
API Usage
Alternative Designs
No response
Risks
No response