Visual Studio: Is there a “move class to different namespace” refactoring?

前端 未结 9 1561
太阳男子
太阳男子 2020-12-20 12:17

I\'m doing some architectural cleanup that involves moving a bunch of classes into different projects and/or namespaces. Currently I\'m moving the files by hand, building, a

9条回答
  •  青春惊慌失措
    2020-12-20 12:45

    This answer applies to at least Visual Studio 2013 and 2015 with no resharper required

    1. Move class files to new folder
    2. Open 'Find and replace'
    3. Select 'Replace in Files'
    4. Type the original namespace definition in the 'Find what' field eg. MyCorp.AppStuff.Api
    5. Type the new namespace definition in the 'Replace with' field eg. MyCorp.AppStuff.Api.Extensions
    6. Select the new folder using the 'Look in' field's browse button ..., or type the folder path
    7. Press the Replace All button

提交回复
热议问题