invio / Invio.Immutable

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

Filter on Auto-Implemented Properties #32

Closed carusology closed 6 years ago

carusology commented 6 years ago

Background

The primary workflow for the ImmutableBase<T> is for it to be a bag of properties with a lot of boilerplate implementations for equality checks, hash code generation, to string representations, and the getting or setting of property values. It does this fine.

What it does not do fine is if someone wants to expose a read-only property that is generated from a collection of other properties. For example, in Invio.Validation.OperationResult, we have a IsSuccessful property that checks if there are any error-level validation issues. This is not a property that is part of the property bag - it is a helper property that is a derivative of other pieces of data.

Based upon the patterns of how we use this data structure, it is the auto-implemented properties that we should be detecting automatically as properties managed by ImmutableBase<TImmutable> - not all properties.

Task

Update our property identification implementation to only include auto-implemented properties by default.

Note

Out of curiosity, I asked on StackOverflow if there was a way to do this. My question was (correctly) marked as a duplicate and was redirected here. This isn't an exact science, but it is worth some tests that can and should be ran on different platforms.