Page MenuHomePhabricator

C#: Refactor struct internal classes
Closed, ResolvedPublic

Description

Currently, for a given struct Foo, the following top level items are generated:

  • struct Foo - The public API struct
  • struct Foo_StructInternal - The internal representation of Foo to be passed to DllImport'd methods.
  • class Foo_StructConversion - With the actual code converting between public and internal structs.

This may pollute the namespace Foo lives, showing the internal items when typing something like new Foo....

In order to hide them, we could:

  • Replace StructInternal with a nested NativeRepr struct inside Foo.
  • Make StructConversion a private class nested inside Foo.
  • Replace the StructConversion calls in parameters.hh with implicit conversion between the NativeRepr and the external struct.