有没有办法禁用 ReSharper Web Form/MVC (.aspx) 括号 ( } ) 完成时的代码格式?
有没有办法禁用 ReSharper Web Form/MVC (.aspx) 括号 ( }
) 完成时的代码格式?
这真的很令人沮丧,而且大多数时候都不是我想要的。例如,如果我有:
<% if (CurrentUser.IsRole(Helper.UserRole.Agent)) { %>
<%= Html.LinkTo("sign out", SessionRoutes.Logout, null, new { @class = "sign" }) %>
<% } else { %>
...
<% } %>
一旦我输入最后一个 <% }
,它的格式如下:
<% if (CurrentUser.IsRole(Helper.UserRole.Agent))
{ %>
<%= Html.LinkTo("sign out", SessionRoutes.Logout, null, new { @class = "sign" })%>
<% }
else
{%>
<%
}%>
我已经查看了 ReSharper 选项,但找不到任何合适的设置。这让我发疯!为了解决这个问题,我要么必须粘贴括号,有时幸运的是 ctrl+z 可以工作,或者输入 <{
然后插入%
然后空格 :S
我相信最近使用过 ReSharper 和 Web 表单的人都会知道我在说什么。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,您应该更改大括号布局选项以匹配您的风格。前往 ReSharper |选项>语言> C#>格式样式>大括号布局>大括号布局并将选项“其他”更改为“行尾处(K&R 样式)”。
接下来,请注意,确实存在一个错误,有时会导致 ReSharper 在 <% 或 %> 之前插入换行符。此错误已在内部版本中修复,并且应该在下一个 EAP(稍后的 2011 年 6 月 7 日)以及未来的 6.0 beta/版本中修复。
如果您愿意,可以在 ReSharper 选项中完全禁用自动格式化(但这不仅会影响 ASP.NET,还会影响常规 C# 文件)。前往 ReSharper |选项>编辑器并关闭分号上的自动格式和右大括号上的自动格式。
希望这有帮助:)
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 :)
您确定是 Resharper 正在执行格式化操作吗? Visual Studio 本身也有一个“自动格式化已完成的块}”选项。
工具|选项>文本编辑器> C#>格式化
Are you sure it's Resharper that's doing the formatting? Visual Studio itself also has an "Automatically format completed block on }" option.
Tools | Options > Text Editor > C# > Formatting
感觉这是这两个错误报告中反映的已知问题: http://youtrack.jetbrains.net /issue/RSRP-193396 和 http://youtrack.jetbrains.net/issue/RSRP-178877
请为他们投票。目前无法保证任何修复时间表,但我希望我们能够尽快修复。
Feels like this is a known issue reflected in these two bug reports: http://youtrack.jetbrains.net/issue/RSRP-193396 and http://youtrack.jetbrains.net/issue/RSRP-178877
Please vote for them. Can't guarantee any fix schedule right now but I hope we're able to fix sooner rather than later.