c# formatting
HI:
I know in the rider setting, there is c# code style section where you can configure how to format your c# code. But i was wondering if there is format plugin or some setting file which we can apply directly apply to rider to format the code same as visual studio style ?
Cheers
Please sign in to leave a comment.
Hi,
Rider is not able to import Visual Studio settings yet. May I ask you how you expect this feature to look like? How you normally share your VS settings between machines and/or teammates?
For now, I'd suggest that you use the new Auto-Detect Formatting Rules feature introduced in Rider 2020.3.x. You can call it on a code snippet:
- Select the code where you'd like to detect the code style
- Call the intentions actions menu on it via Alt-Enter
- Go to Format selection ->Detect formatting settings
Alternatively, you can call auto-detect on your whole solution (which can take some time though):
- Go to File | Settings | Editor | Code Style | C#
- Press Auto-Detect Formatting Rules button:
HI Julia:
zhe wu,
Please accept my apologies for the delayed reply. Indeed, reformatting code with default set of Rider settings doesn't remove empty lines between declarations if there are less than three. To achieve your code style with one blank line between methods, please do the following:
1. Go to File | Settings | Editor | Code Style | C#
2. Open Blank lines tab, scroll to Blank lines in declarations, and set Keep max blank lines in declarations to 1
Rider code formatting rules has a default configuration that takes into account many best practices. I have just checked how Visual Studio with default settings behaves in this case. I can confirm that it doesn't remove empty lines between methods either.
We believe that Rider settings default are always in line with Microsoft guidelines, so our users are not expected to install any additional plugins to achieve that code style. If you notice anything in settings that differs from Visual Studio defaults, please let us know.
Thank you!