【问题标题】:ReSharper cleans our code and changes the using directives so that StyleCop rule SA1200 fails. What to do?ReSharper 清理我们的代码并更改 using 指令,以便 StyleCop 规则 SA1200 失败。该怎么办?
【发布时间】:2011-03-30 08:36:55
【问题描述】:

如果我使用代码清理 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 规则配合使用。

【问题讨论】:

    标签: resharper stylecop


    【解决方案1】:

    最好在 codeplex 项目网站上提交问题:

    http://stylecopforresharper.codeplex.com/workitem/list/basic

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-15
      • 2014-09-23
      • 2015-11-17
      • 2011-08-19
      • 2010-09-14
      • 1970-01-01
      • 2012-03-12
      • 1970-01-01
      相关资源
      最近更新 更多