gpt4 book ai didi

visual-studio - Visual Studio : Is there a "move class to different namespace" refactoring?

转载 作者:行者123 更新时间:2023-12-03 05:29:32 26 4
gpt4 key购买 nike

我正在做一些架构清理,涉及将一堆类移动到不同的项目和/或命名空间中。目前,我正在手动移动文件、构建,然后根据需要手动添加 using Foo 语句来解决编译错误。有人知道更聪明的方法吗? (我们是 CodeRush 和 Refactor! 商店,但我很想知道 Resharper 是否支持此功能)

最佳答案

Visual Studio 2019 提供至少 2 个内置选项:

'Move to namespace...'重构可以在任何类上触发,VS 会提示输入目标命名空间。

'Change namespace to...'当当前文件命名空间与文件夹结构不匹配时,提供重构。

这可用于通过以下方式将各个类移动到不同的命名空间:

  1. 创建所需的文件夹结构
  2. 移动文件
  3. 应用提到的重构(CTRL+.,将光标悬停在命名空间上)

这些操作可确保所有引用都得到相应更新。

关于visual-studio - Visual Studio : Is there a "move class to different namespace" refactoring?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/174193/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com