invio / Invio.Immutable

C# Library used to ease immutable class creation and data management
MIT License
2 stars 0 forks source link

Add `[Calculated]` attribute to denote properties to ignore #42

Open carusology opened 6 years ago

carusology commented 6 years ago

Background

There may be properties on the ImmutableBase<TImmutable> that are not storing relevant data, but instead represent a local caches or syntactic sugar that should actually be ignored when determining the immutable value object's equality, hash code, or string representation.

We should create a [Calculated] attribute that we have consumers flag these properties with so the ImmutableBase<TImmutable> can ignore them.

Task

Add a [Caculated] attribute that ImmutableBase<TImmutable> will look for on all of its child properties and, when found, ignore that property for the purposes of setting it, determining equality, hash code, or string representation. It could, however, be potentially fetched via the GetPropertyValueImpl method.

carusology commented 6 years ago

Not sure on the name here. I've seen an example of a cache, which [Calculated] doesn't quite fit with. However, the cache probably didn't belong on the immutable value object to begin with, but instead on the service that the cached object came from, so it may be irrelevant.