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

visual studio - How can I configure ReSharper's code cleanup on save?

I would love to configure Visual Studio/ReSharper to run "Code cleanup" whenever I save a file.

A bonus would be to configure this only for C# files, as I sometimes find that the cleanup on ASP.NET files does not work without introducing errors.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

You could record a macro(Ctrl+E, Ctrl+C,Run, Ctrl+S). Then run that instead of saving. Then all you need to do is assign CTRL+S to your macro.

Public Module RecordingModule
    Sub CLEAN_AND_SAVE()
    DTE.ExecuteCommand ("ReSharper.ReSharper_CleanupCode")
    DTE.ActiveDocument.Save
    End Sub
End Module

This method will show the code clean-up dialogue box where you will have to select Run.

To remove the user interaction you will have to select a profile to run when Code Cleanup is invoked. You can configure this by going into ReSharper | Options | Tools | Code Cleanup and selecting the profile in "Profile to use with silent clean-up" drop down. Its also here where you can create a custom profile to specify what changes to your code to make. In 4.5 however it does not allow you to omit aspx pages. The only differentiator is C# and VB.Net.

Useful link: http://www.jetbrains.com/resharper/features/code_formatting.html


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

...