Bug 59408 - [generator] Add support for automatically add constructors defined in a base class' api definition
Summary: [generator] Add support for automatically add constructors defined in a base ...
Status: CONFIRMED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools (show other bugs)
Version: master
Hardware: PC Mac OS
: --- enhancement
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-09-12 07:55 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2017-09-12 07:55 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: No
Last known good build:


Attachments

Description Rolf Bjarne Kvinge [MSFT] 2017-09-12 07:55:23 UTC
In Objective-C, constructors are inherited:

> @interface A : NSObject
> -(instancetype) initSomething: (int) something;
> @end
> @interface B : A
> @end

and it's possible to create B like this:

> B * b = [[B alloc] initSomething: 42];

However, when we define this the obvious way:

> [BaseType (typeof (NSObject))]
> interface A {
>     [Export ("initSomething")]
>     IntPtr Constructor (int something);
> }
> [BaseType (typeof (A))
> interface B {
> }

then it's not possible to do this:

> B b = new B (42);

In our bindings we manually fix this, but it becomes tedious: https://github.com/xamarin/xamarin-macios/blob/54058bb8851dc018b5c878e7e85cab6ea5288b59/src/vision.cs#L473-L592, and we've probably missed a lot of cases.

The idea would be to automatically do this in the generator.

Note You need to log in before you can comment on or make changes to this bug.