The T
in Lazy<T>
is marked DynamicallyAccessedMemberTypes.PublicParameterlessConstructor
#112128
Labels
area-System.Runtime
linkable-framework
Issues associated with delivering a linker friendly framework
untriaged
New issue has not been triaged by the area owner
This is presumably there to support the default constructor which instantiates default instances via the Activator, but it creates false positives in AOT compatible projects consuming
Lazy<T>
without using reflection. For example, the following method issues a warning:forcing authors to either suppress the warning or virally add
DynamicallyAccessedMemberTypes
annotations to every generic method consumingCreate
. I'm not aware of any workarounds other than marking the default constructor asRequiresUnreferencedCode
but presumably this would create regressions in trimmed apps using the default constructor. I'm wondering if there's a way we could specifyDynamicallyAccessMembers
on a type parameter in a way that is scoped to a particular constructor overload.cc @vitek-karas @eerhardt for thoughts.
The text was updated successfully, but these errors were encountered: