Frankely Diaz

View Original

Add a rider c# live template for a property with getter and initializer.

Add a rider c# live template for a property with getter and initializer.

I have been using JetBrains Rider for a while now, and recently I have writing code using C# 9 and dotnet 5. One of the features I enjoy from C# 9 is the "Init only setters," if you know what I'm talking about and you use Rider, you'll find this tip helpful. If you don't know what that feature is, check it out here and if you don't know what Rider is, you should check it out here.

1. Go to preferences > Editor > Live Templates > C#

2. Find the “prop” and click on duplicate

Use the existing “prop” C# live template since the only thing you will need to replace is the shortcut name and the set for init.

Go ahead and rename the shortcut name and update the set for init.

3. Save and Use!