Getting ReSharper and VS to play nice with MSpec

Does ReSharper want to make your specs look like this?

Superfluous privates, indentation and warnings

But you want your specs to look like this?

clean text with less noise

Just follow these easy steps:

  1. Go to Resharper>Options

  2. Go to Languages>C#>Formatting Style>Other

  3. Uncheck Modifiers>Use explicit private modifier

  4. Uncheck Other>Indent anonymous method body and hit OK

  5. Go to your project properties>Build and suppress warning 169

  6. Enjoy!

This entry was posted in machine, mspec, resharper. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Aaron Jensen

    This is true for some. For me personally, I don’t miss any of these options.
    To each his own though, I agree it’d be great if R# had per project or
    contextual settings for things like this.

  • bitbonk

    There is just one problem with all of this. It will disable all these valuable and useful settings for the WHOLE SOLUTION, not just the MSpec projects in the solution. It is ONLY the MSpec code that doesn’t need these settings. And I think it is a really bad idea to favor the test over the actual code.

  • Eric Lee

    There’s another setting you’ll want to turn off, at least in RS 5.0. Under Languages | C# | Formatting Style | Other | Align Multiline Constructs, turn off Expression. That will prevent RS from indenting lambda expressions that you put on a second line after the field declaraction like the “It” lines in Aaron’s examples above.

  • aaronjensen

    And I love them!

  • ScottBellware

    Hi Aaron. Everyone in Norway loves you!

  • Peter Seale

    Thanks for pointing me here; these tips are what I needed (especially fixing the crazy indentation!)

  • aaronjensen


    Typing it is easy if you use an AHK script or something similar to replace spaces with underscores like this:

    As for reading it, only you know what's easier to read for yourself. That said, I've seen a post or two on the subject in which the blogger quizzed his wife on which was easier for a long sentence and boxcar always won.

    If you can learn to phase out the underscores while reading it's significantly easier to read. It also allows you to case things properly. I’ve yet to meet someone who has claimed they prefer PascalCasingThingAfterTheyHave given_boxcar_a_shot_for_a_while

  • KevDog

    I’d be interested in a “proof” that boxcar naming is more suitable than pascal case. Personally, I find it hard to read and harder to type. It slows me down and is very awkward.

  • aaronjensen
  • Beto

    What theme are you using?

  • aaronjensen
  • Jason Evans

    Hi there.

    Just looking at the screen shots of your source code, what font are you using in your VS IDE? It looks pretty cool.


  • aaronjensen


    You have obviously completely missed both the point of this post and mspec. That is fine as mspec is a difficult thing to wrap your head around. This post is for people that use mspec and I am assuming you do not.

    With regard to underscores, no setting I have suggested forces you to use underscores in all your code. This is an mspec requirement. It has been proven time and time again that boxcar naming is much more suitable for longer sentence fragments than pascal.

    Calling explicit modifiers “discipline” is just silly, especially considering resharper is set up by default to force you to use them. Replace the word explicit with redundant, which is what thy really are, and maybe you will see my point of view.

    Spend some time in a language like ruby or any other with a high signal to noise ratio and you will find that your biases and predispositions are really baseless.

    Again if you do not even use or see the need for mspec you can write this post off completely.

  • Sergey Shishkin


    underscores in method names is garbage. Explicit access modifiers is discipline. With redundant indentation you’re right, I also customize them.

  • aaronjensen

    169 is unused private. It’s what makes the instance fields (It, Because, Establish, etc) gray, and it can give you a warning when building.

  • Rafferty Uy

    What’s suppress warning 169 for? What is 169?

  • aaronjensen


    Wow. Garbage? Not having superfluous privates and indenting sanely is garbage? If you say so :)

  • Sergey Shishkin

    Nice tip if you only code specs. I don’t want the rest of my code look like garbage.

  • Aaron Jensen


    The language makes your intentions clear. Private is an unnecessary keyword. Any unnecessary ceremony is just that. As such, it should be treated lightly and removed because it does not add value.

    Furthermore, these tips are for the MSpec framework. A framework which has no understanding of “private” so it’s even more superfluous. The entire point of the framework is to remove language noise and focus on the essence of the specs.

    With regards to the indentation, do you indent your method bodies to begin under the ()’s? In MSpec, these initializers are essentially methods, just reshaped. Removing the excess indentation treats them as such.

  • Adam Tybor

    Just what I was looking for… Thanks for posting it. I would love one more showing some of the DRY stuff we talked about.

  • Rohit

    I don’t understand why seeing private declaration is deemed noisy or why it’s a problem to see the indentation tab stopped at the same column as of the previous line. Writing private would definitely make your intentions clear.

  • Nicholas Blumhardt

    Mmm…. Aaron, when I said that was the most twisted C# I’d ever seen, I understated just how cool it is :) Still in awe of this framework!