Skip to content

Conversation

@eerhardt
Copy link
Member

Using MEDI is annotated as RequiresDynamicCode because it supports enumerable and generic servcies with ValueTypes. When using DI with ValuesTypes, the array and generic code might not be available.

At runtime, MEDI checks RuntimeFeature.IsDynamicCodeCompiled and switches to use a pure Reflection based implementation, so the System.Reflection.Emit code is not used with NativeAOT. This allows some limited usages of MEDI to work in NativeAOT, but not all features are supported.

Contributes to #71654

Using MEDI is annotated as RequiresDynamicCode because it supports enumerable and generic servcies with ValueTypes. When using DI with ValuesTypes, the array and generic code might not be available.

Contributes to dotnet#71654
@ghost
Copy link

ghost commented Aug 12, 2022

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost assigned eerhardt Aug 12, 2022
@ghost
Copy link

ghost commented Aug 12, 2022

Tagging subscribers to this area: @dotnet/area-extensions-dependencyinjection
See info in area-owners.md if you want to be subscribed.

Issue Details

Using MEDI is annotated as RequiresDynamicCode because it supports enumerable and generic servcies with ValueTypes. When using DI with ValuesTypes, the array and generic code might not be available.

At runtime, MEDI checks RuntimeFeature.IsDynamicCodeCompiled and switches to use a pure Reflection based implementation, so the System.Reflection.Emit code is not used with NativeAOT. This allows some limited usages of MEDI to work in NativeAOT, but not all features are supported.

Contributes to #71654

Author: eerhardt
Assignees: -
Labels:

new-api-needs-documentation, area-Extensions-DependencyInjection

Milestone: -

@eerhardt
Copy link
Member Author

runtime (Libraries Test Run release mono Linux arm64 Debug) failure is unrelated.

@eerhardt eerhardt merged commit 199436b into dotnet:main Aug 12, 2022
@eerhardt eerhardt deleted the Fix71654 branch August 12, 2022 15:21
@ghost ghost locked as resolved and limited conversation to collaborators Sep 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants