Query on .NET Native: Improve metadata inference #3603
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-enhancement
Milestone
Queries on UWP using the follow LINQ operators are likely to fail:
Queries that use anonymous types will also fail.
Most will fail with a
MissingRuntimeArtifactException
with a message such as :The problem
By default, ILC (IL compilation step of .NET Native) drops all metadata necessary for reflection. Metadata can be included by specifying static rules called runtime directives.
These directives have two limitations leading to our query failures: (1) These compiler directives are static, so they cannot fully determine which metadata is needed at runtime. (2) Directives in our library cannot always retrieve the necessary metadata from user-code types.
Our directives attempt to infer some permutations of user-code types and EF's internal types but cannot cover all cases due the exponential number of permutations (e.g. attempting to infer all valid type arguments of
.Join<T1, T2, T3, T4>()
caused ILC to die after 10 minutes of hogging 2-3 GB of memory).The workaround for users
When our inference fails, users can add their own directives. For example, if a query were to fail with this error message, they could add a directive to their project's rd.xml file shown below.
This has limits however, as directives do not support anonymous types.
Solutions
Improve our directives to reduce the number of directives users must add to make their queries work on UWP.
Use reflection less.
Use reference-type constraints on generic methods. This eliminates the need to properly combine user-types and EF types. Inference with "System.Object" produces metadata than the runtime automatically reuses.
The text was updated successfully, but these errors were encountered: