-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IsDynamicCodeSupported Feature Switch #80246
Conversation
This adds the ability to disable reflection emit for testing. It also allows for applications/libraries to simulate NativeAOT behavior (like switching on RuntimeFeature.IsDynamicCodeSupported) without actually publishing for NativeAOT. Fix dotnet#39806
Tagging subscribers to this area: @dotnet/area-system-reflection-emit Issue DetailsThis adds the ability to disable reflection emit for testing. It also allows for applications/libraries to simulate NativeAOT behavior (like switching on RuntimeFeature.IsDynamicCodeSupported) without actually publishing for NativeAOT. Fix #39806
|
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
Show resolved
Hide resolved
Non-Mono part LGTM |
…ted during CoreLib's build.
...es/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeFeature.NonNativeAot.cs
Outdated
Show resolved
Hide resolved
|
Adds support in the SDK for the new RuntimeFeature.IsDynamicCodeSupported feature switch added in dotnet/runtime#80246. When PublishAot is set in a project, DynamicCodeSupport gets defaulted to false.
…ion (#79425) * Remove RequiresDynamicCode from Microsoft.Extensions.DependencyInjection We need a better approach in order to support applications that use DependencyInjection and publish for NativeAOT. DependencyInjection needs to have reliable behavior before and after publishing for NativeAOT. The application can't work successfully at development-time, but then fail after publishing with PublishAot=true. We will resolve the 2 NativeAOT warnings above by adding a runtime check that is behind the new AppContext switch added in #80246 (`System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported`). The runtime check ensures the Types being used with Enumerable and Open Generic services are only Reference Types. If an application tries to create an Enumerable or Closed Generic service of a ValueType, DependencyInjection will throw an exception. The check is enabled by default when PublishAot=true. Fix #79286
@eerhardt did we opt into this by default on Mono? I think I might need to turn this off for Android apps (haven't checked iOS yet). |
I only set My understanding is that Mono doesn't use the |
This adds the ability to disable reflection emit for testing. It also allows for applications/libraries to simulate NativeAOT behavior (like switching on RuntimeFeature.IsDynamicCodeSupported) without actually publishing for NativeAOT.
Fix #39806
See also dotnet/sdk#29785 for the SDK support for this feature switch.