RequiresUnreferencedCode and RequiresDynamicCode annotations seem too broadly applied #3994
Replies: 1 comment
-
Thanks for raising this — you’ve raised a really valid point around the nuance between using reflection and being unsafe for AOT or trimming. We completely agree that not all reflection is inherently unsafe, and that That said, the current state of ReactiveUI’s codebase makes that very difficult to do without a massive amount of granular work and ongoing maintenance. A lot of these annotations are applied at the class or method level because reflection (often through things like We’ve taken a conservative approach, following Microsoft's guidance to err on the side of caution when annotating libraries for trimming and AOT compatibility. Microsoft themselves often tag whole libraries or classes with these attributes when reflection is used in a way that the trimmer or native AOT compiler cannot reliably analyze. A few useful references from Microsoft:
We’re aware that ❗ ResolutionAt this time, we are going to close this issue as "won’t fix". While we absolutely want ReactiveUI to be AOT-friendly long-term, the current annotations reflect a practical and conservative interim solution. We're open to PRs that help isolate and refine unsafe areas more precisely using Thanks again for the thoughtful feedback — we really appreciate it. |
Beta Was this translation helpful? Give feedback.
-
In #3977 the project was marked with these two annotations in a lot of places:
RequiresUnreferencedCode
means that you are accessing other assembliesRequiresDynamicCode
means that you are generating code at runtimeWhat is the reason for marking so much of the code in the
ReactiveUI
project with these annotations? Is it external dependencies such as Splat Locator that loads types from Assemblies that require unreferenced code?On many classes these annotations are applied on the full class. Rather than, using
DynamicallyAccessedMembers
annotations on types where reflection is actually used.Beta Was this translation helpful? Give feedback.
All reactions