Editing C# in Razor is not the same as editing regular C# - please define separate options for each

My main gripe with ReSharper right now is that Razor inherits settings from the basic C# options, rather than defining its own. The way I format my code in Razor is different to how I format it in regular C# code because of the fact that it's an inherently different environment, with syntactical differences and the fact that it accompanies HTML code. Please provide an option to disable auto-formatting, especially when typing a closing brace, in Razor files. I do not wish to disable this feature when editing .cs files, only when editing .cshtml files. Razor C# != regular C#.

3 comments
Comment actions Permalink

We would certainly look into providing separate option for auto-formatting Razor and ASP.NET on } and ; in 7.0. As for other C# formatting options, I'd like to see a case for them. Could you provide an example where your Razor formatting style differs from C# formatting style?

0
Comment actions Permalink

Sure, so for example, in Razor:

  • I place opening curly braces on the end of the line on which the block starts, instead of on a new line (i.e. like typical JavaScript formatting). This does not reflect the way I write regular C# code.
  • I indent Razor C# code in tandem with the the current html indent level, not where C# code would indent to were it standing alone.


I guess in general I would be happy if I could just say "Don't format my C# code in Razor files". Incidentally, editing C# in Razor files is extremely slow for me, to the point where I type a word and then twiddle my thumbs for a few seconds while the buffer catches up. I like the code analysis in Razor code, but not sure if it's worth it if ReSharper hinders my experience of editing Razor files this much.

0
Comment actions Permalink

I hope that we could satisfy both of your cases in 7.0: option for overriding brace layout style is in plans for *.aspx files, may as well implement it also for *.cshtml, and I hope to have an option to use HTML indent for C# in Razor.
As for typing speed - we take those issues seriously. Could you please follow these steps:
0. Ensure that you are on ReSharper 6.1. There are many performance fixes in that version.
1. Temporary suspend ReSharper (Tools | Options -> ReSharper -> Suspend) and ensure that without it typing speed improves.
2. Turn on ReSharper back and suspend/disable all other extensions in Visual Studio. Ensure that typing speed is still slow (this is important - we have plenty of cases where typing speed issues were caused by third-party plugins such as JIRA).
3. Try disabling tag name synchronizer (ReSharper | Options -> Code Editing | Razor | Editor -> Synchronous changing of matching tag).
4. If nothing helps, please make a performance snapshot ( see instructions here http://confluence.jetbrains.net/display/ReSharper/ReSharper+Profiling+Instructions ) and post a snapshot name here.

Thanks!

0

Please sign in to leave a comment.