Document how to have a get/set property invoke a side-effect on a call to set and still persist the supplied value
See original GitHub issueFrom @DanielRose’s comment in #962
Possibly giving the example that he and @thomaslevesque collaborated on would be best:
A.CallToSet(() => foo.Bar).Invokes((int bar) =>
{
A.CallTo(() => foo.Bar).Returns(bar);
foo.BarChanged += Raise.With(foo, EventsArgs.Empty);
});
although maybe with some cutesy candy shoppe jargon. Or a lovesick robot.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
c# - Why is it impossible to override a getter-only property ...
This enables us to override properties with get / set even if they lacked a setter in their base definition. Situation: Pre-existing get...
Read more >Property getters and setters
Accessor properties are represented by “getter” and “setter” methods. In an object literal they are denoted by get and set :.
Read more >Getters and Setters: Manage Attributes in Python
Typically, getter methods return the target attribute's value, while setter methods take a new value and assign it to the underlying attribute.
Read more >A complete guide to the useEffect React Hook
With useEffect , you invoke side effects from within functional components, which is an important concept to understand in the React Hooks era....
Read more >Custom dependency properties - UWP applications
Explains how to define and implement custom dependency properties for a Windows Runtime app using C++, C#, or Visual Basic.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the ides, @DanielRose. I appreciate the effort you’ve put into looking through the documentation for likely points to add the new information. Some thoughts:
I’d rather not insert code at this point. I think the text here now does convey the default behaviour better than the code would, but if it’s still not clear enough, I’d like to explore non-code ways to explain it first, at least.
The Specifying a call to a property setter section’s focus is more on how to specify which call to override, than actually overriding the code, so I’m again not super excited about putting the sample code in here. A reminder that actually configuring the setter will break the magic get/set relationship, with a pointer to your sample below, sounds like a good idea. The same kind of note could also be added to the Default fake behavior article.
I love this example, despite the lack of lovesick robots. As I sit here, my favourite course of action would be to add it as a “Case study” kind of thing on Invoking Custom Code, which, if I understood you right, was a suggestion you made above.
Thanks, @DanielRose . Look for your name in the release notes! 🥇