Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buddy doesn't work on the C# target. #93

Open
mikkelmr opened this issue Nov 26, 2021 · 4 comments
Open

Buddy doesn't work on the C# target. #93

mikkelmr opened this issue Nov 26, 2021 · 4 comments

Comments

@mikkelmr
Copy link

mikkelmr commented Nov 26, 2021

Running this test on the C# target:

class TestParser extends buddy.SingleSuite {
    public function new() {
        describe("Test something", {});
    }
}

fails with the following error:

haxelib run hxcs hxcs_build.txt --haxe-version 4005 --feature-level 1
src\buddy\Should.cs(529,62): error CS0030: Cannot convert type 'buddy.ShouldInt' to 'buddy.Should<int>'
src\buddy\Should.cs(872,65): error CS0030: Cannot convert type 'buddy.ShouldFloat' to 'buddy.Should<double>'
Compilation error
Native compilation failed
@ciscoheat
Copy link
Owner

Hi, the C# target hasn't been well tested for the last couple of year(s), so I'm not surprised some issues has been introduced. I don't have too much time at the moment, so if you can give it a try and make a PR, that'll be much appreciated. If not I'll take a look when I get an opportunity.

@mikkelmr
Copy link
Author

mikkelmr commented Nov 30, 2021

Fair enough! I word though appreciate it you could point me in a direction of where to look in the source. Just roughly, should I look north or south?

@ciscoheat
Copy link
Owner

ciscoheat commented Nov 30, 2021

Of course. :) The error seems related to should, and the should class is pretty much self-contained, so take a look and see if there are some casting issues there specifically for C#, maybe with the generics.

@mikkelmr
Copy link
Author

mikkelmr commented Dec 31, 2021

Ok, took some time to dig into the problem and it seems to be related to ShouldInt(& ShouldFloat) class that have this construction:

@:keep class ShouldInt extends Should<Null<Int>> which causes the Haxe compiller to produce invalid C# code:
(That is Null<Int> as Type parameter does not work when extending a class with that as type parameter. Have reproduced in an isolated example, but since the C# target has very low priority I don't expect it to be fixed.)

If I change it to @:keep class ShouldInt extends Should<Int> then it compiles but then it's not possible to test for Nullable Int/Float types, so that's not a solution.
But maybe it would work if ShouldInt & ShouldFloat did not extended Should, but instead had the full implementation each. Not the most beautiful solution though.

Btw. it seems that in some cases the ShouldFloat class is used when testing types of Int - haven't quite figured out why that happens. Is this a known issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants