Minor warning with ReadIntoArray in NativeAOT build
#91
Closed
theoractice
started this conversation in
General
Replies: 1 comment
-
|
Thanks for reporting this! For future reports, I suggest using the "Issues" section instead, as I don't receive email notifications for discussions. The good news is v1.3.0 was released yesterday, and it fixes this issue! However, there are some important notes about NativeAOT that you should know—I've posted all the details in the "Release Announcement". |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When building with NativeAOT every warning should be treated carefully, so this is what I asked Copilot:
Copilot says:
You’re hitting the NativeAOT/trimming analyzer rule because Marshal.PtrToStructure requires constructors on T to be preserved, and your generic method doesn’t propagate those requirements. You have two solid options:
Option A — Keep PtrToStructure (works for non-blittable structs)
Example:
Option B — Prefer AOT-friendly, fast copy for blittable types
Example:
Which should I pick?
Hope it helps to mitigate this warning message.
Beta Was this translation helpful? Give feedback.
All reactions