Page MenuHomePhabricator

C#: Replace IntPtr constructor with factory method
Open, NormalPublic

Description

All generated classes currently create a constructor receiving a single IntPtr as a way to wrap a pointer to an Eo obj. This is useful in generated code but can be misleading for the API users.

We should replace it with a static Klass WrapNative(IntPtr) to better convey its meaning and cleanup the contructors list.

For interface concrete implementations (which are used when returning interfaces from methods), this method would return the actual interface instead of the concrete klass. This may help avoiding accidentally declaring Concrete variables, like used to happen in the previous Concrete/Inherit version of the C# API.

lauromoura triaged this task as Normal priority.

After D8550, Concrete classes constructors are private and regular classes intptrs constructors are protected.

Added T7800 as a subtask. After it, we may finally make the IntPrt constructor actually private for regular classes, given C# wrapper instances will be kept alive by the pinning system.