IL2056: A 'System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute' annotation on a property conflicts with the same attribute on its backing field
Cause
Property annotated with DynamicallyAccessedMembersAttribute also has that attribute on its backing field.
Rule description
While propagating DynamicallyAccessedMembersAttribute from a property to its backing field, the trimmer found its backing field to be already annotated. Only the existing attribute will be used.
The trimmer will only propagate annotations to compiler generated backing fields, making this warning only possible when the backing field is explicitly annotated with CompilerGeneratedAttribute.
Example
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
[CompilerGenerated]
Type backingField;
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
Type PropertyWithAnnotatedBackingField
{
get { return backingField; }
set { backingField = value; }
}
Maklum balas
Kirim dan lihat maklum balas untuk