我的任务是对未使用我们当前的代码风格约定编写的遗留代码库进行一些重大修改。这些更改足够广泛,以至于我在开始之前进行了一些清理和重构(有相当多的死代码)。困扰我的一件事是字段遵循 m_FieldName 命名约定,而我们现在使用 _fieldName。
Resharper 是否有某种方法可以自动重命名项目中的所有字段以遵循新约定?还有其他工具可以轻松做到这一点吗?即使通过简单的搜索/替换来删除前缀“m”也不是太困难,但我还没有找到一种自动方法来更改起始字母的大小写。
I've been tasked with making some significant modifications to a legacy codebase that was not written using our current code style conventions. The changes are extensive enough that I'm doing some cleanup and refactoring (there was quite a bit of dead code) before getting started. One of the things that's bugging me is that the fields are following the m_FieldName naming convention whereas we now use _fieldName.
Is there some way with Resharper to automatically rename all fields in the project to follow the new convention? Are there other tools that can readily do this? It's not too difficult to remove the prefixing 'm' with even a simple search/replace, but I haven't found an automated way to change the case of the starting letter.
发布评论
评论(2)
最好使用 Visual Studio(正则表达式搜索/替换)将 查找/替换为
_
。<
代表“单词开头”。编辑:使用查找/替换似乎无法修改下划线后第一个字母的大小写。
因此,您必须连续执行此操作 26 次,如下所示:
然后就万事大吉了。也很有趣:-) 但应该只需要几分钟。
It might be better to just find/replace
<m_
by_
using Visual Studio (regular expression search/replace).The
<
stands for "beginning of word".Edit: There seems to be no way, using Find/Replace, to modify the casing of that first letter after the underscore.
So you would have to do this operation 26 times in a row, like so:
and then you're all set. Fun, too :-) But it should only take a few minutes.
这似乎现在在 Resharper 中可用(我有 v10):
This seems to be available now in Resharper (I have v10):