It works through the new UnsafeAccessorAttribute [1]. This provides the information needed for AOT to know what needs to be in the final binary and not trimmed. It also removes the lookup overhead associated with normal reflection which is very nice.
[1] https://learn.microsoft.com/en-us/dotnet/api/system.runtime....