问题
I use a modified form of TODO comment (SteveC_TODO) that allows me to group my own todos together in the task list.
Yesterday I thought it would be nice to modify the refactoring snippets to add a todo comment to the usual NotImplemented exception. I modified the Method Stub - Body snippet to this
$signature$
{
//SteveC_TODO: implement $end$$signature$
throw new $Exception$();
}
but this results in the todo comment having the full method signature. It serves the purpose but I would prefer the comment to only use the name from the method signature and be of the form
//SteveC_TODO: implement CoolMethod
rather than of the form
//SteveC_TODO: implement private void CoolMethod(object o)
Does anyone know of a way that I can do this? I presume that the arguments passed to refactoring snippets are fixed but perhaps there is a way to parse the $signature$ argument to extract just the name. Anyone know if that might be possible?
回答1:
I think you have to modify it to something like
$accessability$ $returntype$ $method$($arguments$)
{
//SteveC_TODO: implement $method$
$end$throw new $Exception$("The method or operation is not implemented.");
}
You have to declare the literals accessability, returntype, method, arguments,...
Have a look here for how to create codesnippets
来源:https://stackoverflow.com/questions/949825/is-this-possible-with-visual-studio-snippets