脚本代码清理 [英] Scripted code clean up

查看:97
本文介绍了脚本代码清理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,



我只是在考虑一种快速的方法来对c#文件执行重复的步骤,有点像宏。



我想在visual studio 2012中创建一个方法,允许我调用以下步骤。



删除并组织使用声明

查找并替换this。用



如果可能的话



删除使用明确定义的语句,例如



Morning all,

I was just thinking of a quick way to do a repetitive set of steps on c# files, kind of like a macro.

I want to create a method within visual studio 2012 that will allow me to call the following steps.

Remove and organise using statements
Find and replace "this." with ""

And if possible

Remove using statements that are specifically defined, for example

using Point = System.Windows.Point;





修复上述步骤后缺少的命名空间



有关最佳方法的任何建议,以便我能够开始调查吗?



Fix missing namespaces after the above step

Any suggestions on the best approach so I am able to start investigating?

推荐答案

我不知道有什么工具可以帮到你 - 我建议最好在VS之外编写一个应用程序。



但是,我会对这个采取极其谨慎的态度。删除 - 我知道你为什么要这样做,我同意这既丑陋又不必要。但是......有些情况下你需要它:

I don''t know of any tool which will do that for you - I would suggest that it might be best to write an application to do it outside of VS.

However, I would exercise extreme caution with the "this." removal - I know why you want to, and I agree it is both ugly and unnecessary. But... There are cases when you need it:
public int Lines { get; set;}
public MyClass(int Lines)
   {
   this.Lines = Lines + 10;
   }

没有这个。部分代码无法初始化属性。

Without the "this." part the code fails to initialize the property.


这篇关于脚本代码清理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆