openvr
openvr copied to clipboard
Make types in the C# API `partial`
Consider declaring the types in /openvr/headers/openvr_api.cs
with the partial
modifier.
This will greatly simplify integrating the types in applications, because that way the types can be augmented with for example conversion or reinterpret cast operators without touching the autogenerated file.
Can you provide a small diff as an example so I can be sure to get it correct?
Making the declarations partial won't hurt, so just do it for every single declaration of struct
or class
.
Here is how it works:
A minimal diff with the first occurrences of (differently looking) declarations:
-public struct IVRSystem
+public partial struct IVRSystem
-public class Utils
+public partial class Utils
-[StructLayout(LayoutKind.Explicit)] public struct VREvent_Data_t
+[StructLayout(LayoutKind.Explicit)] public partial struct VREvent_Data_t
-public class OpenVR
+public partial class OpenVR
{
- class COpenVRContext
+ partial class COpenVRContext
}
Maybe the generation should be public? There's lots more to improve, but for that you need people who are really into C#. Don't special case Unity. That can be moved out of the #if
and UNITY_METRO
can be replaced with standard .NET defines which people on older .NET can mimic easily with $(DefineConstant)
and the if
inside there can become #if
. Etc.
We've added the scripts used to generate these bindings here: https://github.com/ValveSoftware/openvr/tree/master/codegen