Description
The justification for the trimmer warning suppression does not make sense to me. Yes, PersistentComponentState
's PersistAsJson
and TryTakeFromJson
are "already annotated." That's why it correctly raises a warning when the DefaultAntiforgeryStateProvider
constructor calls these methods.
This might be okay if the static JsonSerializerOptionsProvider.Options used by PersistentComponentState
had a TypeInfoResolver
backed by a JsonSerializerContext
statically generated using [JsonSerializable(typeof(AntiforgeryRequestToken))]
. Otherwise, don't we risk trimming the AntiforgeryRequestToken
constructor which has no callers other indirectly via the JsonSerializer
calls in PersistentComponentState
?
Or better yet, we should probably update PersistentComponentState
to use the JsonOptions
in DI, and register its statically generated JsonSerializerContext
with the TypeInfoResolverChain
similar to what we do for MapIdentityApi and ProblemDetails.