Mital Kakaiya [MCSD.NET]
In Programming, Logic is everything.

Visual Studio 2005 IDisposable interface

Friday, June 17, 2005 12:18 AM

IDisposable is a common interface to release allocated unmanaged resources. Many developers implement IDisposable incorrectly, which causes memory leak inside an application.
More Info: http://www.bluebytesoftware.com/blog/PermaLink.aspx?guid=88e62cdf-5919-4ac7-bc33-20c06ae539ae and http://dotnetjunkies.com/WebLog/rajchaniansbiztalkblog/archive/2005/04/20/69429.aspx

When I wrote Implements IDisposable and press ENTER, Visual Studio 2005 (Beta 2) VB.NET project, it does as follow: (added code snippet automatically):

Great code snippet for VB developers, But Visual Studio 2005 (Beta 2) C# project doesn't support it:

VB.NET code snippet forces developers to implement IDisposable interface based on standard pattern.

Is it possible to develop “custom” interface with a code snippet like IDisposable?


Feedback

# re: Visual Studio 2005 IDisposable interface

VB.NET in VS.NET 2003 supported the functionality you are referring to.

Create an interface, then create a class and type the "implements IMyInterface" and VB.NET IDE will automatically create the stubs for any methods/functions that are required for the supported interface.

If you are referring to the code inside the method, I'm sure that VB.NET 2003 didn't support THAT functionality, and that would be cool to see how we could build the skeleton of a given method when defining an interface. 6/21/2005 7:44 AM | Brian Swanson

# re: Visual Studio 2005 IDisposable interface

Thanks for your comment. I was referring to the code inside the method (snippet), which generates automatically including Finalize() function. I am not sure how to write a code snippet for “custom” interface.

Also, it creates #Region/#End Region tags automatically, which is really nice, as I always prefer to implement an interface inside region tags.
6/21/2005 4:22 PM | Mital Kakaiya [MCSD.NET]

# re: Visual Studio 2005 IDisposable interface

Cool stuff...When we redesigned the Dispose pattern, VB was very quick to notice that this functionality needed to be updated. Glad to see it got done! Very nice! 8/1/2005 6:26 AM | Joe Duffy

# re: Visual Studio 2005 IDisposable interface

Huh,
C# Guys can write Macros ;)))))
4/12/2006 7:52 PM | Surjit Samra

# re: Visual Studio 2005 IDisposable interface

In C# you can right-click on the interface you are implementing and select "Implement Interface"... you then have two options, "Implement Interface" and "Implement Interface Explicitly"... done deal.
9/11/2006 9:20 PM | T

Comments have been closed on this topic.