openvr icon indicating copy to clipboard operation
openvr copied to clipboard

Make code NativeAOT compatible

Open kant2002 opened this issue 3 years ago • 1 comments

I know that C# files are autogenerated, but in case somebody what to use it without waiting for change in code gen tooling. This PR has 3 changes, all of them trivially can be updated in the codegen:

  • Marshal.SizeOf(Type) switched to Marshal.SizeOf<T>()
  • Marshal.PtrToStructure(IntPtr, Type) to Marshal.PtrToStructure<T>(IntPtr)
  • Marshal.PtrToStructure<string>(IntPtr) is gross error, and should be mapped to Marshal.PtrToStringAnsi(IntPtr)

This and #707 should make life of C# developer, amenable and close #638 and #472.

kant2002 avatar Nov 14 '21 14:11 kant2002

Marshal.PtrToStructure<T>(IntPtr) can be replaced by *((T*)IntPtr)

SupinePandora43 avatar Feb 26 '22 04:02 SupinePandora43