GalaxyCheck icon indicating copy to clipboard operation
GalaxyCheck copied to clipboard

Self-reference gen factories

Open nth-commit opened this issue 3 years ago • 0 comments

Discovered while using GalaxyCheck in another project.

public record MyRecord(string A, string B);

public static readonly IGenFactory DefaultGenFactory = Gen
	.Factory()
	.RegisterType(String)
	.RegisterType(DefaultGenFactory
		.Create<MyRecord>()
		.OverrideMember(x => x.A, Gen.Constant("a")));

I want strings to have some default semantics (e.g. only alpha-numeric), but I want the property A to have its own semantics.

This code obviously doesn't work, because DefaultGenFactory is not defined at the place it's used.

Need to add registration methods that take the factory as a callback.

nth-commit avatar Aug 01 '22 07:08 nth-commit