The UnsafeAccessor feature, introduced in .NET 8, allows direct access to private fields and methods without using traditional reflection. Benchmarks show that reading a private field via UnsafeAccessor takes 0.25 nanoseconds, compared to 8.96 nanoseconds for standard reflection. Furthermore, reflection allocates 24 bytes on the heap per access, while UnsafeAccessor performs zero allocations.

The performance gap between reflection and UnsafeAccessor varies significantly across .NET versions and hardware. In .NET 10, reflection was optimized, reducing the latency gap compared to .NET 8, yet it remains substantially slower. UnsafeAccessor works by resolving the field or method once during method compilation, effectively generating machine code equivalent to direct access.

When accessing methods via reflection, additional overhead occurs due to the creation of object arrays for arguments and boxing/unboxing operations, which significantly increases memory allocation. UnsafeAccessor requires the method signature to match the original exactly; otherwise, a MissingMethodException is thrown at runtime.

The feature also supports the UnsafeAccessorType attribute, introduced in .NET 10, which allows referencing types by string name without needing a direct assembly dependency. This is currently utilized within the .NET class library, for instance, to interact with BinaryFormatter or GenericPrincipal.