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
{{ message }}
Repository navigation
ILLink: Trim analyzer doesn't warn on reflection access to annotated members when the source of the Type is GetType on a DAM-annotated class #102002
The following code in Test() should cause warnings to appear on MethodWithDataflow and MethodWithRequires because o is known to be DamOnTypeAccessesMembers which is annotated with DAMT.All, and is passed to RequiresAll, enforcing the requirement. The analyzer should recognize the pattern of Object.GetType() on a statically known type with DAM on the type.
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]publicclassDamOnTypeAccessesMembers{[ExpectedWarning("IL2114",nameof(MethodWithDataflow),nameof(DynamicallyAccessedMembersAttribute),Tool.Trimmer|Tool.NativeAot,"")]publicvoidMethodWithDataflow([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)]Typetype){}[RequiresDynamicCode("--MethodWithRequires--")][RequiresUnreferencedCode("--MethodWithRequires--")][RequiresAssemblyFiles("--MethodWithRequires--")][ExpectedWarning("IL2112","requires unreferenced code","--MethodWithRequires--",Tool.Trimmer|Tool.NativeAot,"")]publicvoidMethodWithRequires(){}publicstaticvoidTest(){varo=newDamOnTypeAccessesMembers();vart=o.GetType();t.RequiresAll();t.ToString();// This triggers the warnings in the analyzer, but not Object.GetType() on DamOnTypeAccessesMembers//typeof(DamOnTypeAccessesMembers).RequiresAll();}}
Activity
dotnet-policy-service commentedon May 7, 2024
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.
Add more issue links to trimmer assertions (#102027)
Add more issue links to trimmer assertions (dotnet#102027)
Make ReflectionAccessAnalyzer logic more similar to ILLink/ILC (dotne…
ILLink analyzer: add warnings for DAM on type (dotnet#105994)
ILLink analyzer: add warnings for DAM on type (dotnet#105994)