Customize my own if else code style

Answered

Hi I'm new to Rider, I am using the trial version.

I want to see if it suits me better than visual studio community which I've been using with Unity for almost the past decade.

 

So one thing that I used to do a lot is a oneliner such as this

if (condition) { continue; }

or

if (condition) { return null; }

I can't seem to find an option that lets me do this style. I dislike not having the curly brackets, but I do not need it to be on multiple lines

The other style that I use is the if-else this way:

if (condition) {

    //my code

} else {

    //My other code

}

 

On an unrelated note I can't find an option to "peek reference" which I use a ton in visual studio, and the "find references" list in visual studio is much easier to navigate than the hierachy in "Find Usage" of Rider. Does anyone have any tips for me about this?

3 comments
Comment actions Permalink

Hello,

To have the oneliner code style as you mentioned, please try option: Preferences | Editor | Code Style | C# | Line Breaks and Wrapping | Place a block with a single simple statement on the same line;

In order to get the code style for if-else, please try: Preferences | Editor | Code Style | C# | Line Breaks and Wrapping | Place "else" on a new line - disable;

There's an action called Quick Definition (Ctrl+Shift+I), which is similar to Visual Studio's Peek Definition. As for Find Usages list, feel free to share your view with creating a cosmetic issue.

0
Comment actions Permalink

Thank you Olga!

I missed these style options. I now have the style that I wanted.

On the other issue though, the Quick Definition action does nothing for me. I tried both the shortcut and activating the action from the "search everything" window (the one you open with shift+shitf).

Any ideas of why it is not working? Maybe the window opens but is hidden for some reason? I'm using windows 10 with 2 monitors of 1440p if that helps.

 

And for Find Usage I realized you can change how the usages are grouped with a button on the left of the "Find" window. By default everything is selected which creates those huge hierarchies. I turned them all off and sometimes switch from Group by File and namespace. This combined with the preview window is great!

Now if I could open that preview Window for a definition with a shortcut (which is what I assume QuickDefinition should be doing) that'd be amazing.

 

0
Comment actions Permalink

Hello,

Thank you for your reply. Happy to help. I beg your pardon for confusing with Quick Definition, the feature is still in the process of implementation, the current status of it can be monitored with the following reference: RIDER-3178

0

Please sign in to leave a comment.