You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current behavior of DAM on types is that any subtype (including itself) of the DAM-annotated type will produce warnings for all members which aren't safe to access via reflection, including members declared on the derived type itself, and members declared on any base types.
This is necessary in cases like #2136 (comment) where some unannotated base type has reflection-unsafe members. But the warnings about base type members are redundant in cases when the base type already has the same DAM annotation (which would already produce this warning on the base type).
For example:
[DAM(DynamicallyAccessedMemberTypes.PublicMethods)]classBase{[RUC("RUC")]publicstaticvoidMethod(){}}// ILLink : Trim analysis warning IL2026: Derived: Using method 'Base.Method()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. RUC.// ILLink : Trim analysis warning IL2026: Derived: Using method 'Derived.MyMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. RUC.classDerived:Base{[RUC("RUC")]publicstaticvoidMyMethod(){}}
We should avoid producing these redundant warnings. In the example the warning about Base.Method is unnecessary as this will already warn elsewhere (with the fix for #2162, on the base type). Note that the warning codes and locations are changing in #2162.
The text was updated successfully, but these errors were encountered:
Note that explicitly re-declared DAM on a type will still warn about base methods, for example:
[DAM(DynamicallyAccessedMemberTypes.PublicMethods)]classBase{[RUC("RUC")]publicstaticvoidMethod(){}}// IL2113: Derived: 'DynamicallyAccessedMembersAttribute' on 'AnnotatedType' or one of its base types references 'Base.Method()' which requires unreferenced code. Using this member is trim unsafe.[DAM(DynamicallyAccessedMemberTypes.PublicMethods)]classDerived:Base{}
The current behavior of DAM on types is that any subtype (including itself) of the DAM-annotated type will produce warnings for all members which aren't safe to access via reflection, including members declared on the derived type itself, and members declared on any base types.
This is necessary in cases like #2136 (comment) where some unannotated base type has reflection-unsafe members. But the warnings about base type members are redundant in cases when the base type already has the same DAM annotation (which would already produce this warning on the base type).
For example:
We should avoid producing these redundant warnings. In the example the warning about
Base.Method
is unnecessary as this will already warn elsewhere (with the fix for #2162, on the base type). Note that the warning codes and locations are changing in #2162.The text was updated successfully, but these errors were encountered: