Is there any way to disable ReSharper Web Form/MVC (.aspx) Code Formatting on Brace ( }
) Completion?
It is really frustrating and most of the time is not what I want. For instance if I have:
<% if (CurrentUser.IsRole(Helper.UserRole.Agent)) { %>
<%= Html.LinkTo("sign out", SessionRoutes.Logout, null, new { @class = "sign" }) %>
<% } else { %>
...
<% } %>
as soon as I type the last <% }
it formats like this:
<% if (CurrentUser.IsRole(Helper.UserRole.Agent))
{ %>
<%= Html.LinkTo("sign out", SessionRoutes.Logout, null, new { @class = "sign" })%>
<% }
else
{%>
<%
}%>
I have looked through ReSharper options, but cannot find any setting suitable. It's driving me nuts! To get around it I either have to paste the bracket, sometimes be lucky enough that ctrl+z works or type <{
then insert the %
then space :S
I'm sure anybody who has worked with ReSharper and web forms lately will know what I'm talking about.
Thanks
First, you should change options for braces layout to match your style. Go to ReSharper | Options > Languages > C# > Formatting style > Braces Layout > Braces Layout and change option "Other" to "At end of line (K&R style)".
Next, please note that there is indeed a bug that sometimes causes ReSharper to insert linebreaks after <% or before %>. This bug is fixed in the internal builds and should be in the next EAP (later that 2011-jun-7) as well as in the future 6.0 betas/release.
If you wish you can completely disable auto-format in ReSharper options (but this would affect not only ASP.NET, but regular C# files as well). Go to ReSharper | Options > Editor and switch off Auto-format on semicolon and Auto-format on closing brace.
Hope this helps :)