Problems when generating internal types
See original GitHub issueI want to test internal
stuff (using InternalsVisibleTo
on the main assembly). Specifically, I want FsCheck to generate instances of internal types. This seems to be a bit hit-and-miss, and mostly seems to fail. For example, generating values of an internal union gives SystemArgumentException
with message X is an F# union type but its representation is private. You must specify BindingFlags.NonPublic to access private type representations. Generation of some other internal types seem to loop until the test times out and gets aborted.
Is this a known issue? Is it deliberate? Would it be possible to make FsCheck able to generate internal types?
Currently I’m just leaning towards making everything public, but that means the public API of the main assembly is rather more noisy than it needs to be.
Issue Analytics
- State:
- Created 6 years ago
- Comments:19 (11 by maintainers)
Top GitHub Comments
I’m on the fence about getting FsCheck to take internal and private constructors into account. I usually use that to signal that the ctor doesn’t do validation or doesn’t necessarily uphold an invariant. I assume that the same problem would exist when FsCheck would be trying to call those ctors. So it can cause some confusion - “why isn’t FsCheck only using my public ctor, it’s generating bogus instances by breaking my encapsulation” type issues.
Ok - that’s fair. Like I said it’s easy to add, and I’m all for un-opinionated tools. I’ll leave it here as a reminder to add.
Nullability - yes it would be great if there was a good way for FsCheck to figure out whether to generate null for ambiguous types like string.