-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Determine whether running in NativeAOT at runtime #94380
Comments
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsIs there any API that can be used to determine at runtime, from a normal, not AOT compiled library, whether the application that includes this library has been published as Native AOT? The only thing I'm aware of is an indirect approach of checking stack trace & the features available there
|
See #76739 |
To be clear that issue was not about Native AOT (it's for Mono AOT). |
Different stack trace handling in Sentry based on the library being included in a NativeAOT-compiled vs "standard" app. We were considering shipping two versions of the library but that would be complicating and we'd likely need to add a new nuget package which is terrible for library consumers. |
It would be more reliable to tie it to the difference in stack trace behavior. IsDynamicCodeSupported will work in .NET 8, but you have to accept it is going to report false even in Mono scenarios (that have different problems for stack traces on Blazor-WASM-AOT) and also when running on top of CoreCLR with JIT sometimes (e.g. adding |
I've done just that, thanks for confirmation that's the right approach for now. #if NET6_0_OR_GREATER // TODO NET7 once we target it
var stackTrace = new StackTrace(false);
IsAot = stackTrace.GetFrame(0)?.GetMethod() is null;
#endif |
Is there any API that can be used to determine at runtime, from a normal, not AOT compiled library, whether the application that includes this library has been published as Native AOT? The only thing I'm aware of is an indirect approach of checking stack trace & the features available there
The text was updated successfully, but these errors were encountered: