Generate Method Stub location

Hi all,

I was wondering if its possible to specify the location of where a method stub is generated. Currently, it always seems to be after the current method, whereas I would prefer it to be always at the bottom of the current class.

This comes about because often I'll define a method that is little more than a list of composed methods, like this:

public DoSomethingUseful()


{
     var result = DoOneThing();
     result = DoAnotherThing(result);
     return DoTheLastThing(result);
}



 

 


As none of these smaller methods have an implementation, they all appear in red, with underlines etc et. I  then use Generate Method Stub on each of them to get a basic implementation, however, starting at the first one, and going on from there, they then appear in the file in reverse order:



public DoSomethingUseful()
{
    var result = DoOneThing();
    result = DoAnotherThing(result);
    return DoTheLastThing(result);
}

private object DoTheLastThing(object result)
{
throw new NotImplementedException();
}

private object DoAnotherThing(object result)
{
throw new NotImplementedException();
}

private object DoOneThing()
{
throw new NotImplementedException();
}



 



But of course, I want them listed in the order they appear in the master method...

Any ideas?

Phil

1 comment

This is a great request!  I have the exact same problem all the time.

However, I am torn about where to put my private methods -- if I pulled out methods for code clarity I want them near where they are used, in the order that they are used.  If I pulled out the method so it could be used in multiple places then I don't know where to put it, only that I want it below the first use.  I don't think there is a perfect answer, but a good heuristic might be "immediately below the first use in the order used."

I don't use the Type Members Layout feature, as I don't think it can do things this sophisticated. Correct me if I am wrong...

0

Please sign in to leave a comment.