invio/Peddler

Make default value in 'MaybeDefault*' implementations configurable

Closed this issue · 0 comments

MaybeDefaultGenerator<T>, MaybeDefaultDistinctGenerator<T>, and MaybeDefaultComparableGenerator<T> all suffer from the same problem: They all assume that default(T) is an acceptable default for an injected generator. While this may often be the case, this is not for something like DateTimeGenerator. In that situation, default(T) will be DateTime.MinValue with a DateTimeKind.Unspecified. However, the caller probably would expect a DateTime.MinValue with the DateTimeKind that the inner DateTimeGenerator utilizes.

By making the concept of "the default" configurable, we allow a consumer to define what "the default" value for an inner generator is. We can certainly give them default(T) if they do not care as we do now.