替换不必要的完全限定类型并在所有类中添加使用
我试图摆脱大量不必要的完全限定类型,而是在这些类的顶部添加 using 。
我不确定是否有某种批次可以为我做这件事。现在我必须使用 ReSharper 并删除类型的冗余部分,当然 ReSharper 会要求添加缺失的 using,这就是我在每个类中手动清理这些内容的方式。
必须有一种更自动化的方法,我可以运行一些流程来遍历此解决方案中的所有项目,并为我执行此操作..就像我必须使用 ReSharper 手动处理每一行代码一样?
I'm trying to get rid of a ton of unnecessary fully qualified types and instead throw in a using at the top of these classes.
I am not sure if there is some kind of batch that would go out and do this for me. Right now I have to use ReSharper and erase the redundant portion of a type and then of course ReSharper asks to throw in the missing using and that's how I am going through each class manually cleaning these up.
There's got to be a more automated way where I can run some process to go through all the project in this solution and do this for me ..just like I'm having to do manually with each line of code with ReSharper?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用代码清理。要在单个文件上运行,请转至 ReSharper |工具|清理代码,选择“完全清理”或使用“优化”使用”指令创建您自己的配置文件,并将“缩短合格引用”设置为“是”。也许“删除代码冗余”也应该转为“是”。
您可以对多个文件运行代码清理。为此,请在解决方案资源管理器中选择必要的文件,按鼠标右键并从弹出菜单中运行代码清理。
You should use Code Cleanup. To run on a single file, go to ReSharper | Tools | Cleanup code, select Full cleanup or create your own profile with Optimize 'using' directives and Shorten qualified references turned to Yes. Maybe Remove code redundancies should be turned to Yes also.
You can run Code cleanup on several files. To do it, select necessary files in Solution explorer, press right mouse button and run Code cleanup from popup menu.