failed samples

Apr 12, 2011 at 5:44 AM

Hi fickerra,

Great project mate.

I've done some small unit tests and they did not port correctly.  I'm using the 0.1 version from the Home tab.  Can you please advise on whether these c# features are supported?  Details below:

---------------------------------------------------------------------

1. Sub class wasn't ported.

c#

class TestFail1
    {
        // Sub classes don't port over
        class SubClass
        {
            public int X;
        }

        public TestFail1()
        {
            var x = new SubClass();
            x.X = 1;
        }
    }

haxe:

class TestFail1
{



    public function new()
    {
        var x:SubClass = new SubClass();
        x.X = 1;
    }
}

---------------------------------------------------------------------

2. property get; set doesnt seem to work - I use this one often

c#

class TestFail3
    {
        public int X { get; set; }

        TestFail3()
        {
            X = 3;
            TestCommon.Assert(X == 3);
        }
    }

haxe - compiler errors

    public var X(get_X, set_X):Int;
    public function get_X():Int
    {
    }

    public function set_X(value:Int):Int
    {
        return 0;
    }

Thanks

Apr 12, 2011 at 10:16 PM

Good finds!  I added these to the Limitations page for now.

I don't believe Haxe has an equivalent to inner classes. Perhaps they could just be implemented as normal classes and the references to it could be renamed on the fly?

Automatic properties could be fixed by CS2HX by automatically generating a hidden private field.  Another option is to just turn this into a normal field, as I don't know of any benefit in Haxe to having a property over just a field.   I believe that turning this into a normal field in Haxe would be a fairly easy change.

Feel free to send me a patch if you fix any of these and I'll be happy to merge it!

May 2, 2011 at 5:00 AM
Edited May 3, 2011 at 1:41 AM

EDIT: supporting default keyword for properties (public var X(default, default):Int;) may not be a good idea because it seems that haxe does not allow mixing default getters with function setters.  eg the following will not compile: public var X(default, set_X):Int;  Therefore it might be best to support the old fashioned way instead and manually create the default behavior so that the default behavior can be mixed with overriding behavior.

ie produce the following code for default behavior:

    public var X(get_X, set_X):Int;
    public function get_X():Int
    {
         return X;
    }
    public function set_X(value:Int):Int
    {
        X = value;
        return X;
    }

flickerra, do you have any time to implement this default behavior?  Otherwise can you point me in the right direction in the code?

Thanks.

May 14, 2011 at 8:28 AM

I just did a check-in that adds support for automatic properties.  Please build the latest version from source to get it.  Check out the unit test project for an example.