Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# VS2012
Morning all,
 
I was just thinking of a quick way to do a repetitive set of steps on c# files, kind of like a macro.
 
I want to create a method within visual studio 2012 that will allow me to call the following steps.
 
Remove and organise using statements
Find and replace "this." with ""
 
And if possible
 
Remove using statements that are specifically defined, for example
 
using Point = System.Windows.Point;
 
Fix missing namespaces after the above step
 
Any suggestions on the best approach so I am able to start investigating?
Posted 10-Jan-13 0:55am
PaulPrice2.1K
Edited 10-Jan-13 5:47am
v2
Comments
Sergey Alexandrovich Kryukov at 10-Jan-13 10:03am
   
Unless you clearly explain the ultimate purpose of it, I doubt anyone will volunteer wasting time for this. As I'm not sure if it makes any sense...
—SA
PaulPrice at 10-Jan-13 10:25am
   
Quite simply I find myself cleaning up an old code base that has a lot (i mean a lot) of redundant statements and using statemebnts that are explicitly decalred as I showed above.
 
I would like to automate this and would like opionions on possible avenues I can investigate. Not full answers as to how to do it.
 
Does that make sense?
Sergey Alexandrovich Kryukov at 10-Jan-13 11:17am
   
You see, this is a pretty modest task. If you want to develop a whole Visual Studio add-on, which is not a very simple task, will it justify all the effort? It it will, just go ahead with Visual Studio add-ons; developing of which is well documented...
A macro? (Sigh...)
—SA
Richard MacCutchan at 10-Jan-13 11:08am
   
I only have the Express editions of VS, but in a previous life I used the pro edition and it allowed you to create (record) and run macros. It should be a fairly simple matter to create a macro that does find and replace for most of the specific cases you have in mind.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I don't know of any tool which will do that for you - I would suggest that it might be best to write an application to do it outside of VS.
 
However, I would exercise extreme caution with the "this." removal - I know why you want to, and I agree it is both ugly and unnecessary. But... There are cases when you need it:
public int Lines { get; set;}
public MyClass(int Lines)
   {
   this.Lines = Lines + 10;
   }
Without the "this." part the code fails to initialize the property.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 120
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100