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
206 views
in Technique[技术] by (71.8m points)

c# - Code Cleanup - tool to move all using statements inside namespace in all cs files in my solution?

After writing a whole bunch of code - i am finally waking up to adding CA and StyleCop to my solution.

By default all files (a lot of them) in my solution have using statements at the top of the file before the namespace.

I have resharper 6.0 and powertools in visual studio. Is there a way using these or any other tool that will go through all my CS file in the solution and put the using statements inside the namespace for each file.

question from:https://stackoverflow.com/questions/8160820/code-cleanup-tool-to-move-all-using-statements-inside-namespace-in-all-cs-file

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

1 Reply

0 votes
by (71.8m points)

With Resharper it can be done in two steps.

  1. Set the checkbox "Add 'using' directive to the deepest scope" in Code EditingC#Code StyleReference qualification. Options v9

  2. In the context menu of the solution choose "Cleanup Code...". SLN context menu

You might want to create a custom cleanup pofile that suits your needs before performing the cleanup.

In ReSharper before v9 the setting is located somewhere else: Options v8


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

1.4m articles

1.4m replys

5 comments

57.0k users

...