Closed BennieCopeland closed 7 months ago
Which version?On 25 Aug 2023, at 04:44, Bennie Copeland @.***> wrote: When using FsCheck in a C# project, I wanted to register the Maybe type from CSharpFunctionalExtensions. I followed the F# example code for creating a Box<> type, but when it came to registering the generator and shrinker, FsCheck is ignoring the static method. I receive an exception "No instances found on type Maybe. Check that the type is public and has public static members with the right signature. using FsCheck;
namespace FooBar;
public class Foo
public TBar Bar { get; }
}
public class FooGenerator
public static Func<Foo<TBar>, IEnumerable<Foo<TBar>>> Shrinker(Arbitrary<TBar> contents)
{
return foo => contents.Shrinker(foo.Bar).Select(v => new Foo<TBar>(v));
}
}
public static class MyGenerators
{
public static Arbitrary<Foo
public class MyPropertyAttribute : PropertyAttribute { public MyPropertyAttribute() { Arbitrary = new[] { typeof(MyGenerators) }; } }
public class MyTests
{
[MyProperty]
public void FooTest(Foo
}
}
If I change the generator registration to remove the Arbitrary
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>
Dotnet Core 7 XUnit test project with FsCheck
and FsCheck.Xunit
at version 2.16.6
Arbitrary methods with Arbitrary arguments are only supported in 3.x if I remember correctly.On 25 Aug 2023, at 09:18, Bennie Copeland @.***> wrote: Dotnet Core 7 XUnit test project with FsCheck and FsCheck.Xunit at version 2.16.6
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
According to the Docs it was supported as of three years ago. I'll check and see if it works in F#. But I also see you're working on 3.0 again, which may make this whole issue moot anyway.
So I checked in F#, and it works just like the docs says it should, so seems like a C# only issue. My workaround works, so if you prefer to close this as "won't fix" to prioritize 3.0, I won't be upset about it.
Those docs are for version 3.x though. Suspect you just happened to use 3.x for your F# test. This is all done via reflection, so not expecting a C# vs F# difference.
This should all work in 3.x...with the usual caveat of "docs updates needed"
When using FsCheck in a C# project, I wanted to register the
Maybe
type from CSharpFunctionalExtensions. I followed the F# example code for creating aBox<>
type, but when it came to registering the generator and shrinker, FsCheck is ignoring the static method. I receive an exception "No instances found on type Maybe. Check that the type is public and has public static members with the right signature.If I change the generator registration to remove the
Arbitrary<TBar>
and move it inside the method block, it works.