Resharper Rename Fields

て烟熏妆下的殇ゞ 提交于 2019-12-12 10:47:18

问题


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.


回答1:


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:

Replace <m_A by _a
Replace <m_B by _b

and then you're all set. Fun, too :-) But it should only take a few minutes.




回答2:


This seems to be available now in Resharper (I have v10):



来源:https://stackoverflow.com/questions/8791762/resharper-rename-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!