VS2005中的代码注释插件

       代码注释有很多风格,纵多开源软件都使用doxygen中几种注释风格的一种。在多个人协作开发一款软件或系统或者项目时,需要统一编码规范。代码的注释也是编码规范的一部分。我们在编写代码注释时为了统一风格,经常使用copy-paste方法,然后再修改不同的部分。为了更方便统一代码注释规范的应用,加快开发中编码的速度,我们在VS2005 IDE中使用代码注释插件,设定相应的快捷键,在使用时只需要按快捷键即可,效果就跟使用VS2005中自带的功能一样,比如在VS2005中选中代码按C-K C-C即可注释掉选中的代码。

     我们使用VS2005中的宏来编写代码注释插件,其宏代码如下:

    

  这里我自己编写的宏代码,有四种代码注释风格,和一个文件注释、一个函数注释功能。其注释风格如:

 

 

     接下来我们简单说一下如何使用这个注释插件。在“工具->宏->宏IDE”先启动宏IDE,然后新建一个宏项目,就上面的宏代码copy进去,接着就在VS2005中绑定快捷键,在“工具->选项->键盘”中选定相应的宏函数,然后分配快捷键。宏中的函数前面注释中的快捷键为推荐的快捷键,自己完全可以跟根自身的喜好来设定。

    比如,我们选中函数getname,然后按C-M C-F(我绑定的是这两个键),然后生成函数上面部分的代码

注:GetFuncInfo GetVarPartFromEnd GetLastWord GetBracketCount HasReturnValue IsVoidKeyWords这几个函数为我自已通过分析字符串来分析函数的参数代码,在查阅文档时发现可以通过.Net的CodeElement(vsCMElement.vsCMElementFunction)过获取函数的相应信息,就对生成函数注释的宏代码进行了修改,这几个函数仅供大家参考,在AddFunctionComment中并没有调用。

 

Visual Studio 十个有用的小插件 无意中发现这么个地方:Ten Essential Tools,上面介绍了十个很好用的插件,以前用过几个,比如:TestDriven.NET,CodeKeep,于是使劲下了下来,但是还有两个找不到下载连接一个是PInvoke.NET 一个是VSMouseBindings,有那位朋友有或知道下载连接的提供一下,谢谢,我把下下来的打了个包,免得后来的朋友一个个找,请到这里下载 Vs10Add-Ins.part1.rar Vs10Add-Ins.part2.rar Vs10Add-Ins.part3.rar TestDriven.NET Test-driven development is the practice of writing unit tests before you write code, and then writing the code to make those tests pass. By writing tests before you write code, you identify the exact behavior your code should exhibit and, as a bonus, at the end you have 100 percent test coverage, which makes extensive refactoring possible. GhostDoc XML comments are invaluable tools when documenting your application. Using XML comments, you can mark up your code and then, using a tool like nDoc, you can generate help files or MSDN-like Web documentation based on those comments. The only problem with XML documentation is the time it takes to write it you often end up writing similar statements over and over again. The goal of GhostDoc is to automate the tedious parts of writing XML comments by looking at the name of your class or method, as well as any parameters, and making an educated guess as to how the documentation should appear based on recommended naming conventions. This is not a replacement for writing thorough documentation of your business rules and providing examples, but it will automate the mindless part of your documentation generation. Smart Paster Strings play a large role in most applications, whether they are comments being used to describe the behavior of the system, messages being sent to the user, or SQL statements that will be executed. One of the frustrating parts of working with strings is that they never seem to paste correctly into the IDE. When you are pasting comments, the strings might be too long or not aligned correctly, leaving you to spend time inserting line breaks, comment characters, and tabbing. When working with strings that will actually be concatenated, you have to do even more work, usually separating the parts of the string and inserting concatenation symbols or using a string builder. CodeKeep Throughout the process of software development, it is common to reuse small snippets of code. Perhaps you reuse an example of how to get an enum value from a string or a starting point on how to implement a certain pattern in your language of choice. PInvoke.NET P/Invoke is the process used to access native Win32 API calls within the .NET Framework. One of the hard parts of using P/Invoke is determining the method signature you need to use; this can often be an exercise in trial and error. Sending incorrect data types or values to an unmanaged API can often result in memory leaks or other unexpected results. VSWindowManager PowerToy The Visual Studio IDE includes a huge number of different Windows, all of which are useful at different times. If you are like me, you have different window layouts that you like to use at various points in your dev work. When I am writing HTML, I like to hide the toolbox and the task list window. When I am designing forms, I want to display the toolbox and the task list. When I am writing code, I like to hide all the windows except for the task list. Having to constantly open, close, and move windows based on what I am doing can be both frustrating and time consuming. WSContractFirst Visual Studio makes creating Web services deceptively easy You simply create an .asmx file, add some code, and you are ready to go. ASP.NET can then create a Web Services Description Language (WSDL) file used to describe behavior and message patterns for your Web service. VSMouseBindings Your mouse probably has five buttons, so why are you only using three of them? The VSMouseBindings power toy provides an easy to use interface that lets you assign each of your mouse buttons to a Visual Studio command. CopySourceAsHTML Code is exponentially more readable when certain parts of that code are differentiated from the rest by using a different color text. Reading code in Visual Studio is generally much easier than trying to read code in an editor like Notepad. Cache Visualizer Visual Studio 2005 includes a new debugging feature called visualizers, which can be used to create a human-readable view of data for use during the debugging process. Visual Studio 2005 includes a number of debugger visualizers by default, most notably the DataSet visualizer, which provides a tabular interface to view and edit the data inside a DataSet. While the default visualizers are very valuable, perhaps the best part of this new interface is that it is completely extensible. With just a little bit of work you can write your own visualizers to make debugging that much easier. Wrapping It Up While this article has been dedicated to freely available add-ins, there are also a host of add-ins that can be purchased for a reasonable price. I encourage you to check out these other options, as in some cases they can add some tremendous functionality to the IDE. This article has been a quick tour of some of the best freely available add-ins for Visual Studio. Each of these add-ins may only do a small thing, but together they help to increase your productivity and enable you to write better code.
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值