Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This makes field/property initialization opt-in instead of opt-out.
It is a breaking change, as it replaces the
DoNotPreserveInitializers
config attribute with one namedPreserveInitializers
. It also changes the default behavior, thus breaking, again.The solution
As this is a recently introduced feature and EmptyConstructor.Fody has a long history I assume it's not covering a very common use case. Therefore I'd say it's entirely fine to be opt-in instead of opt-out.
Given the current implementation is buggy, in a breaking way makes it very sensible to be opt-in instead of opt-out.
Furthermore, I suppose the author of the feature, @NorekZ, does not (currently) require the bug to be fixed, thus there is no immediate pressure to fix it and it may well take quite some time to have it fixed. This speaks for making it opt-in, at least until it's stable.
A perfect implementation of the feature could be quite complicated, anyway.
Furthermore I deem it an advanced feature because it's a bit difficult to understand what exactly it does. This speaks for making it opt-in forever (or until we know better).
To sum it up: make it opt-in and leave it like that.
I've also considered making this a less-breaking change by only changing the default value of
DoNotPreserveInitializers
, but not the name.Here's my reasoning not to:
All existing users only (had to) introduced the flag in case it wasn't the intended behavior. All of them now have to ensure that all their FodyWeavers.xml have the correct config. The reduced burden of maintaining this (when adding new projects etc.) should outweigh the negative effect of having to remove the attribute.
All users who haven't updated yet might be better off by changing the default behavior and won't be affected by the name change.
Thus, only the users who prefer the feature to be on remain as "victims". Those won't be many, as the feature has only been introduced very recently.
@SimonCropp do you think that's a fair evaluation?
Todos