Description
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)]
class Base {
[RUC("RUC")]
public static void Method() {}
}
// 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.
class Derived : Base {
[RUC("RUC")]
public static void MyMethod() {}
}
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.