记得在VS2003刚刚发布的时候,曾经给VS项目经理写过一封信询问下个版本中是否会加入关于Refactoring的支持,但是那位老兄的说法是这部分功能应该由第三方软件而不是MS完成,呵呵。不过随着主流IDE开发环境如Eclipse/JBuilder等都增加了重构的支持功能,VS2005也加入了相应的功能。同时一些第三方厂商也提供了针对VS2002/VS2003的重构支持。
刚刚在纯朴的狗熊的主页上看到对VS.NET下重构工具的介绍文章《.NET下的重构》。于是下载了一个C# Refactoring Tool试用了一下,感觉虽然功能不如Java的开发环境下那么强大,但是基本功能点还是足够了,非常不错,决定留用了,呵呵 :D
以下为引用:
C# Refactoring Tool version 1.5.1 announcedFeatures
Refactorings
Encapsulate Field updated
Extract Method
Inline Temp
Introduce Explaining Variable
Move Member (Field, Method) updated
Rename (Field, Method, Property, Local Variable, Parameter, Type, Namespace) updated
Replace Magic Literal with Symbolic Constant updated
Replace Temp with Query
Integrated with MS Visual Studio .NET (as Add-in)
Undo/Redo in MS Visual Studio .NET
Solution Level Processing
可惜要注册,没有$奉上只好顺手剁了,用用先 :P
虽然程序本身写的还不错,但感觉作者的注册机制做的真是很搞笑,呵呵
用VC7写了一个 Unmanaged 的 DLL (DotNetRefactoring.Verify.dll)用于完成实际注册码解码工作,同时用一个 Managed C++ 的 DLL (DotNetRefactoring.VerifyWrap.dll)对其功能进行封装。但因为封装得太好,导致只要把 DotNetRefactoring.Verify.dll 删掉或者随便用个DLL替换,都会导致验证失败,但是无法弹出警告对话框。同时只需要写一个具有相同导出函数的 Unmanaged DLL,就可以“完成”注册码的解码工作...-_-b
只需要先在注册表的 HKEY_LOCAL_MACHINESOFTWARE.NET RefactoringC# Refactoring Tool 下面增加一个名为 Key 的字符串,如
以下为引用:
Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINESOFTWARE.NET RefactoringC# Refactoring Tool]
"Key"="Flier Lu"
然后用VC7写一个 Unmanaged Win32 DLL,导出一个类,然后替换 DotNetRefactoring.Verify.dll 即可。(仅供试用,请勿用于非法用途 :P)
以下为引用:
// DotNetRefactoring.Verify.cpp : Defines the entry point for the DLL application.
//#include "stdafx.h"
#include <stdlib.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
return TRUE;
}#ifdef DOTNETREFACTORINGVERIFY_EXPORTS
#define DOTNETREFACTORINGVERIFY_API __declspec(dllexport)
#else
#define DOTNETREFACTORINGVERIFY_API __declspec(dllimport)
#endif// This class is exported from the DotNetRefactoring.Verify.dll
class DOTNETREFACTORINGVERIFY_API CVerify {
public:
static char *decryptString(const char *msg);CVerify& operator=(const CVerify& v);
static void remove(char *msg);
};char *CVerify::decryptString(const char *msg)
{
char buf[1024] = "Licensed to ";strcat(buf, msg);
return strdup(buf);
}CVerify& CVerify::operator=(const CVerify& v)
{
return *this;
}void CVerify::remove(char *msg)
{
free(msg);
}