Skip to content

Conversation

@thomhurst
Copy link
Owner

Summary

  • Fixed the FsCheck custom generators documentation example which used the deprecated FsCheck 2.x API (Arb.Default.Int32().Filter())
  • Updated to use the correct FsCheck 3.x Fluent API with ArbMap.Default.GeneratorFor<T>()
  • Added alternative examples and test coverage

Problem

The documentation example at https://tunit.dev/docs/examples/fscheck/#custom-generators didn't compile because Arb.Default is internal in FsCheck 3.x (the version used by TUnit.FsCheck).

Changes

  • Use ArbMap.Default.GeneratorFor<T>() instead of Arb.Default
  • Use .Where() for filtering and .ToArbitrary() to convert generators
  • Added alternative example using Gen.Choose for simple ranges
  • Added custom types example showing LINQ composition
  • Added test coverage in TUnit.Example.FsCheck.TestProject to verify the documented pattern works

Test plan

  • Build succeeded
  • New PositiveNumbersArePositive test passes with custom arbitrary

Fixes #4619

The documentation example used the FsCheck 2.x API (Arb.Default.Int32().Filter())
which is no longer available in FsCheck 3.x. Updated to use the correct
FsCheck 3.x Fluent API with ArbMap.Default.GeneratorFor<T>().

Changes:
- Use ArbMap.Default.GeneratorFor<T>() instead of Arb.Default
- Use .Where() for filtering and .ToArbitrary() to convert
- Added alternative example using Gen.Choose for simple ranges
- Added custom types example showing LINQ composition
- Added test coverage for the documented pattern

Fixes #4619
@claude
Copy link
Contributor

claude bot commented Jan 30, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@thomhurst thomhurst merged commit 0b2b97d into main Jan 30, 2026
11 of 13 checks passed
@thomhurst thomhurst deleted the fix/fscheck-custom-generators-docs branch January 30, 2026 11:37
This was referenced Feb 1, 2026
This was referenced Feb 2, 2026
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

Successfully merging this pull request may close these issues.

[Bug]: FsCheck Custom Generators Example from Doc is not working

2 participants