Visual Studio的代码清理功能介绍

自Visual Studio 2019起,加入了一个新功能:代码清理

它的作用是格式化代码并应用当前设置中配置的代码修复程序。

 

可以通过如下方式启动

1、【分析】菜单->代码清理

2、状态栏代码清理按钮

image

 

默认情况下,Visual Studio为代码清理功能配置了如下的修复程序

image

 

执行【代码清理】功能后,将会自动执行上面的修复程序。 

 

我们也可以对【代码清理】功能进行配置

1、通过【分析】菜单->代码清理->配置代码清理

image

2、通过状态栏按钮

image

 

可以配置的项较多,可以根据自已需求进行添加或删除。

image

 

参考资料:

https://learn.microsoft.com/en-us/visualstudio/ide/whats-new-visual-studio-2019?view=vs-2019#code-cleanup

https://learn.microsoft.com/zh-cn/visualstudio/ide/code-styles-and-code-cleanup?view=vs-2019&pivots=programming-language-dotnet

posted @ 2025-08-28 15:08  zhaotianff  阅读(83)  评论(0)    收藏  举报