Create and initialize private/public readonly auto-property context action for ReSharper.
Build statuses
master | feature |
---|---|
Create private, private read-only and public read-only properties quick fix:
Live templates:
The plugin was inspired by the discussion about Auto Properties in C# language. http://stackoverflow.com/questions/3310186/are-there-any-reasons-to-use-private-properties-in-c
The primary usage of this in my code is lazy initialization, as others have mentioned.
Another reason for private properties over fields is that private properties are much, much easier to debug than private fields.
I frequently want to know things like "this field is getting set unexpectedly; who is the first caller that sets this field?"
and it is way easier if you can just put a breakpoint on the setter and hit go. You can put logging in there.
You can put performance metrics in there. You can put in consistency checks that run in the debug build.
Basically, it comes down to : code is far more powerful than data.
Any technique that lets me write the code I need is a good one.
Fields don't let you write code in them, properties do.
(c) Eric Lippert
ReSharper 8.2 (Not supported anymore): https://resharper-plugins.jetbrains.com/packages/MrEric/
Latest ReSharper: https://resharper-plugins.jetbrains.com/packages/Sizikov.MrEric/