-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
I'm not sure how you would solve this, but if you set some field in your constructor, Dossier overrides it with what it thinks should be the default. This is particularly annoying with collections, since the default Dossier chooses is to set collection properties to null, rather than an empty collection. The workaround we're using is to override BuildObject and call .Set(GetOrDefault() ?? EmptyCollection)
on every collection field.
Some possible solutions that I see:
- Some way to indicate that Dossier should skip certain fields, unless someone's called Set on them
- Make all fields opt-in, and provide an easy way to say "give this a sensible default"
- Read the value of a field first, and if it's not the default value for that field, then set it to some reasonable default
- Change the handling so that an empty list is the default for ICollection properties, Enumerable.Empty is the default for IEnumerable properties, etc.