Cannot control TypeProperties even with a custom binder
See original GitHub issueI was trying to figure out why AutoBogus was doing nothing with the RepeatedField<T> type (a protobuf type). I created my own binder to try and take control of the situation, but it never even called GetMembers.
Digging into the code a bit, I found that this line does not pass the provided binder onto the base class. Therefore, the base class uses the default binder to populate TypeProperties. Hence, I never get a chance to even tell it that I want to populate my RepeatedField<T> instances.
By changing the above line to this:
: base(locale ?? AutoFaker.DefaultLocale, binder)
I got around my problem. However, when I went to PR this, I noticed a couple of tests broke, and I was then well and truly out of my depth.
Any thoughts on this? Ultimately, I just want my RepeatedField<T> instances to populate like any other list would.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)

Top Related StackOverflow Question
Hi @kentcb
I finally found some time to look into addressing your use case. I have made some code changes that allow you to register an override for a type generator (including the built in generators).
In the case of your example above you would implement the following:
That should provide an entry point for customizing the generation of a given type. Does that work for you? If so, I will publish a new version to NuGet.
Nick.
Hey @kentcb
If you are ever interested in using AutoBogus again, I have just released v2.3 which includes the ability to define generator overrides. An example of how to applies these to generics can be found in the
Playgroundproject.I’ll close this issue now.
Nick.