-
Notifications
You must be signed in to change notification settings - Fork 30
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
Using linear and exponential ranges from C# #156
Comments
That's weird... We're using |
Is this happening when you use Hedgehog from C#? |
Yes, it was. |
The issue seems to be happening in here fsharp-hedgehog/src/Hedgehog/Numeric.fs Line 277 in 9a95b50
(Called from here) fsharp-hedgehog/src/Hedgehog/Range.fs Lines 109 to 114 in 9a95b50
On my local, I get a more specific exception actually:
|
Seems to be specific to C#, but haven't tried with VB.NET... |
For performance reasons it's probably better to not go via BigInt as well, we could change the generators perhaps... |
Sure, but what the alternatives are? |
I mean for the specific types like Int32 and so on we could generate them directly and not generate a BigInt first. We'd still need the BigInt version for generic numerics. |
I just got this exception, and when I googled it I landed on this github issue and found I had already upvoted it 😄 I'm sure you know all this by now, but just to document it explicitly here: For example
(plus some metadata for F# consumers, I've not used this in quite some time so I forget but it doesn't matter anyway here) The workaround is to just not call such functions from C# 🙂
and then call that instead in their C# code and yes it's cumbersome but things will just work. I'd suggest mangling the compiled name of such functions so that C# callers don't accidentally call them. |
Mauricio (@mausch), thank you for commenting and for the analysis 👍
Couldn't we just remove the
Perhaps... we can add those in a module and include it with the library? 🤔 |
Hi Nikos,
Unfortunately this will only expose the function to C# callers as
Sure, it could be done ideally, my PR was just about preventing the exception :-) |
Something like this should do : https://github.com/mausch/fsharp-hedgehog/commit/29b29b52dc1d86dfff498fd284ed9e6413c1e3ac |
👍 It looks like we need both, then. PR #219, and another one based on https://github.com/mausch/fsharp-hedgehog/commit/29b29b52dc1d86dfff498fd284ed9e6413c1e3ac. |
So now that #219 is merged, I started the tedious process of copypasting all the overloads for all these static inline functions ( see https://github.com/mausch/fsharp-hedgehog/commit/d5ac038d1f370fce2b449b4bc1f18272e2360cbc ). |
@mausch, in Visual Studio Community 2019 (16.7.5) this appears to work [<EditorBrowsable(EditorBrowsableState.Never)>] I've sent you https://github.com/mausch/fsharp-hedgehog/pull/1/files — curious to see if it works in Rider and/or Ionide. 👀 |
Duh! That defeats the whole purpose and they're now also hidden globally 😥 |
FWIW, in Visual Studio Community 2019 (16.7.5) they are pushed to the end of the autocomplete list. |
Rider has an option to sort the autocomplete list by name, and then these I think #222 is a reasonable workaround for now, even if it's obviously not ideal. Many years ago I attacked these F# -> C# interop issues with some helper functions to convert e.g. FSharpFunc <-> Func , and while that does make things usable most of the time, of course it can't be as good as an interface specifically designed for C# . |
@Porges @moodmosaic I think this is possible to do now, should we consider this done? |
Yes, we should. 👍 |
When using
Range.Linear
I got this:Range.Constant
works fine, so I'm sticking with that at the moment. I can't see any obviousNotSupportedException
uses in the code around line 155...The text was updated successfully, but these errors were encountered: