Default to get-only properties?

I use Create Property a lot. I have member generation set to make auto-properties. Unfortunately, rider always adds a setter to my properties and there doesn't seem to be a way to configure it not to. Is there a way to use Create Property and have it default to readonly/get-only properties?



Hi Dave Cousineau

Do you use prop to generate properties? If so, there is a live template. It can be changed in `File | Settings | Editor | Live Templates | C# => prop`. Remove getter from the template and save or create a copy with get-only. 

If you use Generate (Alt+Enter), there is an option to create read-only property

I hope this helps! 


Ok I didn't realize that get-only properties were a different option in the list from just properties. Thanks.


K now that I've tried it in my usual situation it doesn't work. If I write, for example:

class test {
public test() {
Value = 5;

If I then use Alt-Enter on the property Value that doesn't exist yet, I don't have a get-only property option, only "Create Property 'Value'" is available, which makes a get; set; auto property. If I have to do this for 10+ properties, that's a lot of setters that I have to manually delete.


Hi Dave! 

You're right, there is no option to generate get-only properties. I've created a feature request for this: RSRP-489798. Feel free to upvote it! 

As a workaround, one can change all such properties at once using Alt+Enter - Make auto-property get-only -> in file (see screenshot). 


I hope this helps! Should you have any other questions, let us know. 



Please sign in to leave a comment.