Monday, May 21, 2012

Coding templates - auto property at top of code file

It might seem like a small problem, but I was wondering if there is any support from either Visual Studio or a 3rd party application to configure where Visual Studio places certain auto-generated code.



When I am programming, I try to be as efficient as possible, and use 'Ctrl+.' a lot to automatically implement interfaces, fields, properties etc.. and one of the issues i have is that EVERY time I want to create a property in a class file (by typing in the usage first, then Ctrl+. the red invalid text, choosing Generate Property Stub when prompted) is Visual Studio places the code at the very bottom of the class file.



This is not how I structure my code files, and for better or worse I would much prefer it if the Auto-Properties were generated at the top.



So instead of (as would happen on auto-generation)



public class ObjectProvider
{
public ObjectProvider(Object o)
{
this.Object = o;
}

public object Object { get; private set; }
}


I would prefer



public class ObjectProvider
{
public object Object { get; private set; }

public ObjectProvider(Object o)
{
this.Object = o;
}
}


A small change I know, but when I am coding (at the least!) 5 days a week, for about 40 hours - I think this would actually save me a lot of time!





No comments:

Post a Comment