Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Cause
The target location declares some requirements on the type value via its DynamicallyAccessedMembersAttribute. Those requirements must be declared by the source value also via the DynamicallyAccessedMembersAttribute. The source value can declare more requirements than the target, if necessary.
Example
Type GetCustomType() { return typeof(CustomType); }
void NeedsPublicConstructors([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type type)
{
// ...
}
void TestMethod()
{
// IL2072 Trim analysis: 'type' argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to 'NeedsPublicConstructors'. The return value of method 'GetCustomType' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
NeedsPublicConstructors(GetCustomType());
}
Fixing
See Fixing Warnings for guidance.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.