You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
I think that would make sense as a default, as long as it was possible to remove. Would it make sense to fill collections with anonymous values too, at least for simple types like ints or strings?
On reflection to avoid breaking changes I'd like to keep the current default, but I think there is value in providing anonymous value suppliers to do both things so that the user can decide to add them to the global (or local) suppliers.
Do either of you want to have a go at adding anonymous value suppliers for your suggestions?
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:
The text was updated successfully, but these errors were encountered: