ReSharper 清理了我们的代码并更改了 using 指令,以便 StyleCop 规则 SA1200 失败。该怎么办?
如果我使用 Code Cleanup ReSharper 功能,我会得到这样的文件开头:
using System.Web.UI;
[assembly: WebResource("Company.Web.Resources.foo.js", "application/x-javascript")]
namespace SiteSeeker.Web.WebControls
{
using System;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
using System.Web.UI;
....
但是,这会触发 SiteCop 规则“SA1200:所有 using 指令必须放置在命名空间内。”。有没有办法配置 ReSharper 将装配线变成:
[assembly: WebResource("Company.Web.Resources.foo.js", "application/x-javascript")]
这样我就可以得到文件的开头:
[assembly: System.Web.UI.WebResource("Company.Web.Resources.foo.js", "application/x-javascript")]
namespace SiteSeeker.Web.WebControls
{
using System;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
using System.Web.UI;
....
这不会导致 StyleCop 生气。或者我应该走这条路线并停用 SiteCop 规则?我们希望在 ReSharper 中使用代码清理,因为它很方便并且几乎符合我们的 StyleCop 规则。
If I use the Code Cleanup ReSharper feature I get this start of a file:
using System.Web.UI;
[assembly: WebResource("Company.Web.Resources.foo.js", "application/x-javascript")]
namespace SiteSeeker.Web.WebControls
{
using System;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
using System.Web.UI;
....
However this triggers the SiteCop rule "SA1200: All using directives must be placed inside of the namespace.". Is there a way to configure ReSharper to turn the assembly line into:
[assembly: WebResource("Company.Web.Resources.foo.js", "application/x-javascript")]
So that I get this beginning of the file:
[assembly: System.Web.UI.WebResource("Company.Web.Resources.foo.js", "application/x-javascript")]
namespace SiteSeeker.Web.WebControls
{
using System;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
using System.Web.UI;
....
Which will not cause StyleCop to get angry. Or should I go the route and deactivate the SiteCop rule? Use Code Cleanup in ReSharper is something we would like to, as it is convenient and almost works with our StyleCop rules.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好在 codeplex 项目网站上提出问题:
http://stylecopforresharper.codeplex.com /workitem/list/basic
It's probably best to file an issue on the codeplex project site:
http://stylecopforresharper.codeplex.com/workitem/list/basic