Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
745 views
in Technique[技术] by (71.8m points)

visual studio - How to reformat naming styles with ReSharper?

I have several pages of code that need to have naming styles reinforced, e.g. use fooBar instead of FooBar for local variables. I don't want to correct it one by one for an obvious reason.

I tried to fiddle with the code cleanup profiles accessiable via ReSharper > Tools > Cleanup Code > Edit Profiles. I am not able to find a way to correct all naming style in one hit, or even with a keyboard shortcut. Could seasonsed ReSharper users advise how I can tackle this problem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I don't believe ReSharper has a way to do a bulk rename like you want. Changing the C# Naming Styles will certainly highlight (as warnings) those local variables that need changing, but Code Cleanup won't correct them for you.

There are times when renaming a variable to match a convention might result in one symbol colliding with another symbol that already exists; I imagine that's why ReSharper doesn't allow the bulk rename.

Two ReSharper shortcuts may make this pretty quick (and this is assuming you have adopted ReSharper's shortcut keys for Visual Studio):

  1. Alt + PgDn - Go to next highlight (error, warning or suggestion). This will let you get from one misnamed variable to the next quite quickly.
  2. Alt + Enter - Open the "Quick Fix" menu and select "Rename...". This will rename the variable and update all references.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...