Constructor with default arg not called by default from child class on iOS


(James Esword) #1
public class TestBaseClass {

    public readonly int type;

    public TestBaseClass(int t = 999) {
        type = t;  // won't be called by default from child class
    }
}

public class TestClass : TestBaseClass {
    public TestClass() {}
}

[UIApplicationMain, IBObject]
class AppDelegate : IUIApplicationDelegate {
    public UIWindow window { get; set; }

    public BOOL application(UIApplication application) didFinishLaunchingWithOptions(NSDictionary launchOptions) {
        window = new UIWindow(UIScreen.mainScreen().bounds);
        window.rootViewController = new UIViewController withNibName(null) bundle(null);
        window.makeKeyAndVisible();

        // print "type=0" on iOS, but "type=999" on .NET/Android
        NSLog("type=" + new TestClass().type);

        return true;
    }

Is it possible to unify this behavior for different platforms? For C#, it’s better to call that base constructor by default.


(RemObjects) #2

Thanks, logged as bugs://75925


(RemObjects) #3

bugs://75925 got closed with status fixed.