-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Generate AotHelper properties at compile time #2927
Comments
For reference: dotnet/runtime#94380 |
I assume this would cover some previously edge cases where the SDK wrongly assumes NativeAOT on unsupported platforms (i.e. UWP)? |
I think initially when we were building AOT support, we identified and tried to avoid (at runtime) code that would throw errors when compiling AOT. It may well be trimming, rather than AOT, that prevents those code blocks from running however and we should probably change our runtime guards to check for trimming rather than AOT. Currently if sentry-dotnet/src/Sentry/Internal/AotHelper.cs Lines 13 to 34 in 9f36d22
I think that's a problem though. It's entirely possible to build Then we have code like this: sentry-dotnet/src/Sentry/Internal/DebugStackTrace.cs Lines 179 to 181 in 233e95b
So it doesn't execute some potentially problematic code if |
If I get that right then we could get around this issue on UWP by updating the check instead of having to rely on a dedicated package? |
Possibly. We still wouldn't be able to hook up the unhandled exception handler automatically as that relies on reflection... but that's not a huge issue (people can copy/paste 6-7 lines of code to hook that up)... and I think there is some device information we can't capture without a dedicated UWP library since gathering that relies on Windows Native libraries. |
A couple of different options
Use built in attributes
The RuntimeFeature.IsDynamicCodeSupported Property looks like it might do what we want in many cases (I think we're using
AotHelper.IsNativeAot
where we should probably be checking for Trimming compatibility instead in some cases). Need to do a search for uses ofAotHelper.IsNativeAot
and a bit of a review of these.Generate these at compile time
For this AotHelper, instead of:
sentry-dotnet/src/Sentry/Internal/AotHelper.cs
Lines 18 to 19 in 217c11c
Could we instead write an attribute at compile time? I imagine it's a lot cheaper (worth measuring) than trying to get a stack trace on a static constructor:
Something like this:
sentry-dotnet/src/Sentry/buildTransitive/Sentry.targets
Lines 8 to 29 in 217c11c
Here's a PR that added writing the attribute at build time as a reference: #1739
Originally posted by @bruno-garcia in #2920 (comment)
References
The text was updated successfully, but these errors were encountered: