Tuesday, December 02, 2008

ctor snippet upgrade

According to the StyleCop you should put this comment above constructor.

///
/// Initializes a new instance of the MyClass class.
///



In order to do this automatically you can use SnippetDesigner (or you can do it by yourself) to change default ctor snippet.
It should be:

///
/// Initializes a new instance of the $classname$ class.
///

public $classname$ ()
{
$end$
}


Snippet location is:
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC#\Snippets\1033\Visual C#\ctor.snippet

2 comments:

About Marjan Panic said...

Hi Mijalko :)
Really usefull post.
Did you found any snippet that creates constructor with all class parameters - not only default one?
Thanks
MP

Mijalko said...

I am not sure if you can create snippet that will take custom number of parameters. But I found very useful tool: GhostDoc. Create constructor with custom number of parameters, run ghost doc and (if you give good names for properties) you will get as good comment as it is possible for one bot (sometimes I am really pleasant surprised). Of course, you can use ghostdoc for commenting any method, not just constructor.