How to turn off graying out unused usings?

后端 未结 2 1078
一个人的身影
一个人的身影 2021-01-12 07:02

How (supposing it\'s even possible) to turn off the Visual Studio 2015 feature to gray out unused usings (usings in C#, Imports in VB) ?? I like all the other highlight / s

2条回答
  •  庸人自扰
    2021-01-12 07:49

    If the unused using is actually useful (i.e. shortens names of types in documentation comments when you pause your mouse over a member outside debug mode). You can suppress the warning for those usings with #pragma warning disable:

    #pragma warning disable IDE0005 // Using directive is unnecessary
    

    To resume the behavior in the file, you would use #pragma warning restore.

    #pragma warning restore IDE0005 // Using directive is unnecessary
    

    Do be warned, as of VS 2017 15.6.6, the menu option for Remove and Sort Usings will ignore the #pragma warning disable directives. As I think this is a bug, I will be submitting a roslyn issue.

提交回复
热议问题