如何在 Visual Studio 2015 中为完全合格的使用禁用灯泡? [英] How can I Disable Lightbulb for Fully Qualified Usings in Visual Studio 2015?

查看:24
本文介绍了如何在 Visual Studio 2015 中为完全合格的使用禁用灯泡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:

命名空间 My.Namespace.Admin.Presenter{使用系统;使用 System.Collections.Specialized;使用 System.Globalization;使用 My.Framework.Utility;使用 My.Namespace.Core.Business.Admin;使用 My.Namespace.Core.Entities.Admin;...}

在 Visual Studio 2015 中,这被灯泡标记为改进IDE0001:Name Can by Simplified

  • My.Framework.UtilityFramework.Utility
  • My.Namespace.Core.Business.AdminCore.Business.Admin
  • My.Namespace.Core.Entities.AdminCore.Entities.Admin

我不喜欢灯泡建议,我该如何关闭它?这些似乎没有全局设置,单击 IDE0001 错误只会执行

然后编辑规则集.IDE* 规则位于分析器 Microsoft.CodeAnalysis.CSharp.Features 下:

将 IDE0001 更改为 none(或将它们全部更改为 none),并且不再触发该规则.

它不够细化,只能去掉命名空间 IDE0001,但确实去掉了它以及 IDE0001 的其余建议",这足以满足我的需要.

创建的规则集可以根据需要应用于所有项目.

I have:

namespace My.Namespace.Admin.Presenter
{
    using System;
    using System.Collections.Specialized;
    using System.Globalization;

    using My.Framework.Utility;
    using My.Namespace.Core.Business.Admin;
    using My.Namespace.Core.Entities.Admin;

    ...
}

In Visual Studio 2015, this is flagged as an improvement by the lightbulb IDE0001: Name Can by Simplified for

  • My.Framework.Utility to Framework.Utility
  • My.Namespace.Core.Business.Admin to Core.Business.Admin
  • My.Namespace.Core.Entities.Admin to Core.Entities.Admin

I don't like the lighbulbs suggestion, how can I turn it off? There doesn't seem to be a global setting for these and clicking the IDE0001 error just performs a bing search rather than a dedicated help page.

This question deals with another issue flagged by IDE0001, but not the namespacing.

解决方案

This can be achieved via creating a Code Analysis Ruleset

In project properties select the Code Analysis tab -

Then edit a ruleset. The IDE* rules are under the Analyzer Microsoft.CodeAnalysis.CSharp.Features:

Change IDE0001 to none (or all of them to none), and the rule isn't fired anymore.

It's not granular enough to only get rid of the namespace IDE0001, but does get rid of it along with the rest of IDE0001 "suggestions" which is good enough for my needs.

The created Ruleset can be applied to all projects as needed.

这篇关于如何在 Visual Studio 2015 中为完全合格的使用禁用灯泡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆