- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 984
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
Support for F# anonymous records #2530
Comments
BDN generates a C# project that references the F# project and generates a Here is the logic that generates the C# code: https://github.com/dotnet/BenchmarkDotNet/blob/master/src/BenchmarkDotNet/Code/CodeGenerator.cs Here is the template it's filling: |
I'm guessing F# anonymous records are implemented similar to C# anonymous types where their underlying type name in IL cannot be expressed in C#. If that's the case, there is nothing we can do about it. You will have to wrap it in another type that C# can consume (or up-cast to |
Very well might be - in that case yeah, at least a proper error message would be helpful. I haven't worked with debugging BDN yet but this looks like an interesting opportunity. Will post heads up here if I start working on this. |
I think the only way for this to work would be for someone to create a toolchain that generates F# source code and fsproj the way the It's also impossible for us to detect build errors such as this before actually running the build, so the only thing we can do is report the build error, which already occurs. |
From experimenting with #2336, I found that C# is perfectly capable of calling the F# method, as long as the return type is not used at all. It may not be broadly applicable (we still can't use anonymous types for args/params), but it's interesting that this particular case is possible to make work. Of course, that's blocked by the results of #2334, but I thought it could be handy to leave the findings here. |
Thanks for the investigation @timcassell. Indeed, this probably doesn't have to be addressed in general - even in a few annoying cases (like this one) we handled, it would be nice. |
Repro
What happens
What should happen
Well something more clear. It should either work or give a clear message. This might be related to the fact that anon records in F# are very generic under the hood and AFAIK BDN has problems with those.
Env
The text was updated successfully, but these errors were encountered: