Search code examples
.netvb.netintellisensedisposeusing

Why does IntelliSense not offer Dispose on DataTableReader?


Essentially, I have a DataTableReader object and I was reviewing my code to make sure everything disposable was indeed disposed of.

DataTableReader implements IDisposable, but IntelliSense doesn't seem to be picking up on it:

enter image description here

It does however work with other disposable classes, such as FileStream:

enter image description here

So, what gives? DataTableReader IS disposable, right?


Solution

  • It's because the DbDataReader's Dispose method has the EditorBrowsableAttribute set to Never basically telling VS to not show it. Why? I am not sure.

    [EditorBrowsableAttribute(EditorBrowsableState.Never)]
    public void Dispose() {
        Dispose(true);
    }
    
    protected virtual void Dispose(bool disposing) {
        if (disposing) {
            Close();
        }
    }
    

    Source: https://referencesource.microsoft.com/#System.Data/System/Data/Common/DbDataReader.cs,f7c2de36229de361