Closed bddckr closed 5 years ago
Run this annotated method ...
InternalSetup
.One could argue all of these needs can be reduced to Run this method, and given its signature pass in some values or use the returned value as the value to set the property to.
That gives all the needed flexibility as long as all signatures are supported.
The method would be annotated with [CalledBySetter(nameof(thatProperty))]
and would first only support a subset of all signatures and later, via another ticket, all of them will be supported.
I'm reducing the scope of this task down to only support a single method signature, namely void MethodName(T previous, ref T new)
. The weaver should remember the previous
value at the start of the setter method, then call the annotated method at the end of the setter.
This allows all use cases and only has a single downside to it in case one only needs a specific value or none even: You are forced to use that single supported method signature. This doesn't seem like a big issue after all and in case it is a new issue can be raised for it in the future.
:tada: This issue has been resolved in version 8.0.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
This is an enhancement to
PropertySetterMethod
.The allowed signatures that make sense are:
T MethodName(T previous, T new)
T MethodName(T new)
(One can still call the getter to get the current value. Bonus points for checking the parameter name and logging a warning if it looks like the user was thinking this is some kind of "prev" value.)T MethodName(T previous, ref T new)
T MethodName(ref T new)
(Bonus points, see above.)void MethodName(T previous, T new)
void MethodName(T new)
(Bonus points, see above.)void MethodName(T previous, ref T new)
void MethodName(ref T new)
(Bonus points, see above.)void MethodName()
Still need to decide whether this makes sense and which of these to support.