Description
Several reflection calls lack proper [DynamicallyAccessedMembers] annotations, which can cause runtime failures under AOT trimming.
PropertyInjector.cs (Lines 244, 387, 393, 409)
Direct calls to metadata.ContainingType.GetProperty() without [DynamicallyAccessedMembers] annotations in InjectSourceGeneratedPropertyAsync and RecurseIntoNestedPropertiesCoreAsync. While methods have [UnconditionalSuppressMessage] for source-gen, the actual calls lack proper safeguards.
JsonExtensions.cs (Lines 68, 80)
classParameterTypes[i].FullName ?? "Unknown"
Accesses FullName without checking for null Types. Generic type parameters or constructed types might return null FullName. No DynamicallyAccessedMembers annotation on input types.
Suggested Fix
- Annotate
metadata.ContainingType with [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
- Add null coalescing:
classParameterTypes[i]?.FullName ?? classParameterTypes[i]?.Name ?? "Unknown"
Description
Several reflection calls lack proper
[DynamicallyAccessedMembers]annotations, which can cause runtime failures under AOT trimming.PropertyInjector.cs (Lines 244, 387, 393, 409)
Direct calls to
metadata.ContainingType.GetProperty()without[DynamicallyAccessedMembers]annotations inInjectSourceGeneratedPropertyAsyncandRecurseIntoNestedPropertiesCoreAsync. While methods have[UnconditionalSuppressMessage]for source-gen, the actual calls lack proper safeguards.JsonExtensions.cs (Lines 68, 80)
Accesses
FullNamewithout checking for null Types. Generic type parameters or constructed types might return nullFullName. NoDynamicallyAccessedMembersannotation on input types.Suggested Fix
metadata.ContainingTypewith[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]classParameterTypes[i]?.FullName ?? classParameterTypes[i]?.Name ?? "Unknown"