Generate method stub on code with too many {
I just noticed that when you try to generate a method stub on code where there are more {
than }
, the method stub gets generated incorrectly.
For instance:
static void Main(string[] args) {
myMethod();
}
creating a method stub for myMethod()
expands correctly into:
static void Main(string[] args) {
myMethod();
}
private static void myMethod() {
throw new NotImplementedException();
}
However! If I now continue and add:
{
newMethod();
And try to generate a method stub for newMethod()
, I get this:
static void Main(string[] args) {
myMethod();
{
newMethod();
}
private
private static void newMethod()
{
throw new NotImplementedException();
} static void myMethod() {
throw new NotImplementedException();
}
}
Can I configure Visual Studio somehow as to do it correctly? Or is this something that would have to be repor开发者_如何学JAVAted to someone?
I think this is a case of garbage in, garbage out.
If your code is written in such a way that it's impossible for the auto-generation tools to tell where one code block ends and another begins then I wouldn't expect it to be able to produce meaningful results.
If you consider this behavior a bug, I recommend reporting it to Microsoft Connect.
Of course, the simple solution is to have well-formatted code prior to using code gen and automated refactor routines. I can't imagine how the text editor could "correctly" handle the potentially-unlimited variety of malformed code.
精彩评论