How can I make all of the IDisposable classes colored differently in the Visual Studio IDE?

前端 未结 7 1402
小蘑菇
小蘑菇 2021-01-07 21:47

Title covers it all. I\'d like classes which implement IDisposable to show up in a specific color so I can know if I should wrap them in a using block. Is there a setting

7条回答
  •  长发绾君心
    2021-01-07 22:01

    Maybe I'm a bad person for doing this, but I've been using this piece of code recently:

    public static void BulkDispose(object[] objects)
    {
      foreach (object o in objects)
      {
        if (o != null)
        {
          if (o is IDisposable)
          {
            IDisposable disposable = o as IDisposable;
            disposable.Dispose();
          }
        }
      }
    }
    

提交回复
热议问题