Orchard CMS requires that all commits to the core use the JavaScript style curly brace positioning, where the opening brace is on the same line as the method signature. If you use ReSharper then it comes with an automatic .resharper file that applies this out-of-the-box but non-users can still get this functionality with plain vanilla Visual Studio.
This isn’t a post against ReSharper at all, I think its great, but its not-free so not every developer has it. If you are wanting to contribute to the Orchard core, write a blog post about Orchard with code or just have your custom modules look like they are part of the rest of the code this quick tip will let you get the brace positions the same.
What’s the difference?
Lets take a simple example. A normal install of Visual Studio would format a piece of code like this:
The opening curly braces each start on a fresh line. Orchard favours the more terse JavaScript style approach with the curly braces:
How do I do it?
It’s just a few checkboxes within the options panel:
Click Tools | Options…
Scroll down to the Text Editor node
Expand the C# node
Expand the Formatting node
Click on the New Lines node
You will see a list of options like in the image below which give you full control over when Visual Studio should put your open brace on a new line. Remove the check’s from all of the checkboxes in the “New line options for braces” section.
Click OK
When you change this setting it will change it for all of your projects, so if you switch between Orchard and non-Orchard projects you will have to come back and re-enable these settings.
Older versions of Visual Studio
You might not see these options. Some of the older versions of Visual Studio showed simplified settings by default. It seems like (in Visual Studio Community 2015 at least) that it defaults to showing all the settings now.
If you can’t follow the steps above then look for a Show all settings checkbox in the bottom corner of the Options dialog.