views:

133

answers:

3

Hello,

Let's say I have 100 winforms in folder Forms. All form classes belong to ProjectName.Forms namespace. I want to move all those forms to folder WinForms and I want their namespace to change to ProjectName.WinForms.

Is there a way to do this automatically without manually changing each form's namespace? I have a Resharper, but didn't find any options that could help.

Thank you in advance.

+1  A: 

For these types of scenarios I usually use some shell script magic (you'd need cygwin and/or Perl or the like). Something like:

for i in *; do perl -pi -e 's/ProjectName.Forms/ProjectName.WinForms/g' $i; done

I suppose VS probably has some sort of broad search and replace functionality built in, too.

jess
+1  A: 
womp
nightcoder
You shouldn't be using widespread fully qualified references like that anyway, for exactly this reason.
womp
+1  A: 

You can use Replace In Files and restrict the replacement to a specific folder, and also to match to whole words which will avoid unwanted replacements.

First off, replace all 'namespace ProjectName.Forms' with 'namespace ProjectName.WinForms' then if you have any dependent code replace 'using ProjectName.Forms;' with 'using ProjectName.WinForms;' in that.

(Edit: assuming c#)

Stuart Dunkeld