How to remove all useless new lines in automatic properties in an entire solution

Say you have someone on the team that for whatever reason keeps changing back the corresponding VS settings (or even worse, wasting keystrokes) and formats automatic properties like so:

public string Foo
{
    get;
    private set;
}

Say you got tired of freakin' fixing this manually every time to the much more readable and less wasteful default format:

public string Foo { get; private set; }

Well, in order to replace each and every match for the wasteful version with the concise, readable and default version, just do a File & Replace in all files in the solution, using Regular Expressions matching, and use:

Find What: {:i}\n:b*\{\n:b*{.*}get;\n:b*{.*}set;\n:b*\}

Replace With: \1 \{ \2get; \3set; \}

 

image

This will even preserve the property visibility modifiers, like in the example above.

Read full article

Published 22 September 2010 05:03 PM by Daniel Cazzulino
Filed under: ,

Comments

No Comments

Search

Go

This Blog

News

     

      Microsoft MVP Profile

Syndication