Page MenuHomePhabricator

C#: Replace IntPtr constructor with factory method
Closed, WontfixPublic


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.

lauromoura closed this task as Wontfix.Jun 26 2019, 2:24 PM

Well, making these constructors private would mean that we would have to add empty default constructors above in the inheritance tree, and these constructors wold have to be visible somehow. So, the current protected constructors with the remark of being only for internal use seems to be enough.