Ten essential tools that each .NET developers should download [Repost]

xiaoxiao2021-03-06  39

Each .NET developers should download the ten necessary tools: James avery Original Source: .NET Tools: Ten Must-Have Tools Every Developer Should Download Now This article has added new information since the release. See the editing update below. The tools discussed herein are as follows:

NUnit: Writing unit test Tool NDOC: Tools for Creating Code Documents Nant: Tools for Generating Solution CODESMITH: Code Generating Tool FxCop: Used - Code Police Snippet Compiler: Small Code Segment Compilation Tool Two Different Conversions Tool, ASP.NET version converter (Version Switcher) and Visual Studio RegulaTr: Generate regular expression tools. Net Reflectle: Juvenum Analysis Check Tool This article uses the following technology: .NET, C #, Visual Basic .NET, Visual Studio .NET unless you use the best tool you get, don't expect to generate first-class applications. In addition to Visual Studio .NET, you can get many small, less known tools from the .NET community. I will introduce you to the best free tools for .NET development to you. Net development. I will lead you to complete a quick tutorial about how to use each tool - some tools can save your time in many occasions, while others may completely change the way you write code. Because I want to introduce such different tools in this article, I can't discuss each of the tools in detail, but you should fully understand the information of each tool to determine which tools are useful for your project. Snippet Compiler Snippet Compiler is a Windows-based small application that you can write, compile and run the code through it. If you have a smaller code segment, and you don't want to create a complete Visual Studio .NET project (and all files included with the project), the tool is useful. For example, suppose I want to demonstrate how to launch another application from the Microsoft .NET framework. In Snippet Compiler, I will start with newly built a file that can create a small console application. You can create a code snippet inside the main method of the console application, and this is exactly what I want to do here. The following code snippet demonstrates how to create a notepad from the .NET framework: System.Diagnostics.Process Proc = new system.diagnostics.process ();

Proc.startinfo.filename = "notepad.exe";

proc.start ();

Proc.WaitForexit (); of course, the code snippet is not compiled, which is the land of Snippet Compiler. Figure 1 shows this code example in Snippet Compiler. Figure 1 Snippet Compiler Running Schedule To test the code snippet, you only need to press the Play button (green triangle), it will run in debug mode. This code snippet will generate a pop-up console application and will display a notepad. When you close a notepad, the console application will turn off. I personally, I am trying to create a small sample for someone who has someone who has a person who has been seeking. Snippet compiler is a priceless treasure - if not using the tool, then I usually have to create a new project to make sure each The part can be compiled, and then the code snippet is sent to the help, and finally remove the item. Snippet Compiler makes this process easier and cool. Snippet compiler is written by Jeff Key, the download address is: http://www.sliver.com/dotnet/snippetCompiler Regulator Regulator is recently added to my headwide tool list. It is a very distinctive tool that makes it easy to generate and test regular expressions. Since the regular expression is excellent in the .NET framework, people have reorganized regular expressions. Regular expressions are used to define patterns in strings based on characters, frequencies, and character sequences. Their most common use is a means of verifying user input validity or as a method of looking up a string in a larger string - for example, looking for a URL or email address on a web page. Regulator allows you to enter a regular expression and some inputs to run this expression. This way, before implementing the regular expression, you can understand what effect it will generate and which type of matching item will return. Figure 2 shows the Regulator with a simple regular expression. The Figure 2 Regulator Running screen document contains the regular expression - in this example, it is [0-9] *, which should match any number of numbers in a row. In the lower right side contain inputs for this regular expression, and the lower left side of the box displays the matching item found in the input content. This is easier to write and test regular expressions in separate applications. It is much easier than trying to handle them in your own application. One of the best features in Regulator - is available in regexlib.com to search online regular expressions. For example, if you enter a string "Phone" in the search box, you will find 20 variable expressions that match the various phone numbers, including expressions for the British, Australia and many other phone numbers. Regulator is written by Roy Osherove, the download address is: http://royo.is-a-geek.com/regulator CodeSmith CodeSmith is a template-based code generation tool that uses syntax similar to the ASP.NET to generate any type. Code or text. Unlike many other code generation tools, CODesmith does not require you to subscribe to a specific application design or architecture. With CODesmith, you can generate anything including simple strong types and complete applications. When you generate an application, whether you write a data access code or a custom collection, you will find that some specific tasks often need to be done. At this time, CODesmith is particularly useful, because you can write templates to automate these tasks, not only improve your work efficiency, but also automatically complete those most boring tasks.

CoDesmith has many templates, including templates corresponding to all .NET collection types, and templates for generating stored procedures, but the truly power of this tool is to create custom templates. In order to make you get started, I will quickly introduce how to generate a custom template. Generating Custom Templates The CODESMITH template is just some text files that can be created in any text editor. The only requirement is to save them with the .CST file extension. I will generate the sample template will accept a string and then generate a class based on the string. The first step in creating a template is to add a template head, which can declare the language, target language, and brief template for template: <% @ CODETEMPLATE LANGUAGE = "C #" TargetLanguage = "C #"

Description = "Car template"%> The next part of the template is the property declaration, where you can declare the properties that will be specified at the template each time. As far as this template is, the only property I want to use is just a string, so the attribute declaration is as follows: <% @Property name = "classname" type = "string" category = "context"

Description = "Class Name"%> This property declaration will cause the className property in the CodeSmith property window so that it can be specified at the template runtime. The next step is to actually generate a template main body, which is very similar to encoding with ASP.NET. You can view the main body of the template in Figure 3. [Edit Update - 6/16/2004: The code in Figure 3 has been updated so that the multi-threaded operation is safe. ] As you can see, this template accepts string input and uses this class name to generate a separate class. In the template body, use the same start and end tags as in ASP.NET. In this template, I just insert the attribute value, but you can also use any type of .NET code inside these tags. After this template is complete, you can load it to CODesmith by double-clicking it or from the CodeSmith application. Figure 4 shows the template that has been loaded into CODesmith. Figure 4 CODESMITH template You can see the properties on the left is the properties I declared in this template. If I enter "Singletonclass" as class name, and click the Generate button, generate the category displayed at the bottom of Figure 3. CODesmith is used quite easy. If it is possible to properly, some incredible results can be generated. One of the most common parts of the code-generated application is the data access layer. Codesmith includes a special assembly called SchemaExplorer, which can be used to generate templates from tables, stored procedures, or almost any other SQL Server? Object. CODESMITH is written by Eric J. Smith, the download address is: http://www.ericjsmith.net/codesmith NUnit NUnit is an open source unit test framework generated for .NET Framework. NUNIT allows you to write tests in your favorite language, thus testing specific features of your application. When you first write code, the unit test is a good way to test code functions, which also provides a method of regulating the application. The NUnit application provides a framework for writing unit tests, as well as a graphical interface running these tests and viewing results. Write a NUnit test as an example, I will test the function of the HashTable class in the .NET framework to determine if two objects can be added and these objects are retrieved. My first step is to add a reference to the NUNIT.FRAMEWORK assembly, which will give me access to the properties and methods of the NUnit framework. Next, I will create a class and mark it with the testfixture property. This property enables NUNIT to know that the class contains NUnit test: use system; use system.collections;

Using nunit.framework;

Namespace NUNITEXAMPLE

{

[TestFixTure]

Public class hashtabletest {

Public hashtabletest () {

}

}

} Next, I will create a method and mark it with the [Test] property so that NUnit knows that this method is a test. Then, I will build a HashTable and add two values ​​to it, and use the assert.Arequal method to see if I can retrieve the same value as the value added to the HashTable, as shown in the following code: [Test]

Public void hashtableaddtest ()

{

Hashtable ht = new hashtable ();

Ht.Add ("Key1", "Value1"); HT.Add ("Key2", "Value2");

Assert.Arequal ("Value1", HT ["Key1"], "Wrong Object Returned!");

Assert.Arequal ("Value2", HT ["Key2"], "Wrong Object Returned!");

} This will confirm that I can first add a value to the HashTable and then retrieve the corresponding value - this is a very simple test, but it is possible to show the function of NUnit. There are many test types and various Assert methods, which can be used to test each part of the code. To run this test, I need to generate a project, open the generated assembly in the NUnit application, and then click the Run button. Figure 5 shows the results. When I saw the big green stripe, I had an excitement and dizzy feel because it let me know that the test has passed. This simple example shows how convenient and powerful NUnit and unit tests. Since you can write a saved unit test, you can re-run the unit test whenever you change the code, you can not only detect the defects in your code, but ultimately you can deliver a better application. Figure 5 NUnit NUNIT is an open source project, the download address is: http://www.nunit.org/. There is also an excellent NUnit Visual Studio .NET plug-in, which allows you to run unit testing directly from Visual Studio. You can find it at http://sourceforge.net/projects/nunitaddin. For more information on NUNIT and its status in test-driven development, please refer to article: "Test-Driven C #: Improve The Design and Flexibility of your Project with extreme programming techniques" FXCOP .NET framework is very powerful, this means it is very likely Create an excellent application, but there is also the possibility of creating inferior programs. FXCOP is one of the tools that help create better applications, check whether it meets these rules by analyzing the assembly and uses many different rules. FXCOP comes with a set of rules created by Microsoft, and you can also create and include your own rules. For example, if you decide that all classes should have a default constructor without any parameters, you can write a rule to make sure that each class of the assembly has a constructor. In this way, no matter who writes the code, you will get a certain degree of consistency. If you need more information about creating a custom rule, see John Robbins about this BugSlayer column article. So let's take a look at what actually runs FXCOP and pay attention to it in the NUNITEXAMPLE program I are developing. When you open FXCOP, you first need to create a FXCOP project, then add the assembly you want to test. After adding the assembly to the project, you can press Analyze and FXCOP will analyze the assembly. Figure 6 shows the errors and warnings found in this assembly. Figure 6 FXCOP Running FXCOP has found several questions in my assembly. You can double-click an error to view details, including rule instructions, and where you can find more information. (You can do an interesting thing is to run FXCOP on the framework assembly and see what happened.) FXCOP can help you create better, more consistent code, but it does not compensate for poor application design or Very simple and poor programming. FXCOP can also replace the peer code check, because it can capture a lot of errors before performing code check, so you can spend more time to solve serious problems, but don't worry about naming conventions.

FXCOP is developed by Microsoft, downloading the address: http://www.gotdotnet.com/team/fxcop Lutz Roeder's .NET Reflector Next Miss .Net Reflector, it is a class browser and anti-compilation To analyze the assembly and show you all the secrets. The .NET framework introduces the reflection concept that can be used to analyze any .NET-based code (whether it is a single or complete assembly). Reflection can also be used to retrieve information about the various classes, methods, and attributes included in a particular program. Using .NET Reflector, you can browse the class and methods of the assembly, you can analyze the Microsoft Intermediate Language (MSIL) generated by these classes and methods, and can be used to compile these classes and methods and view C # or Visual Basic? Net Equivalent classes and methods. In order to demonstrate the mode of work of .Net Reflector, I will load and analyze the NUNITEXAMPLE assembly that has already been displayed in front. Figure 7 shows the assembly loaded in the .NET Reflector. Figure 7 NUNITEXAMPLE assembly is within .Net Reflector, there are various tools that can be used to further analyze the assembly. To view MSIL constituting a method, click this method and select DisasseMbler from the menu. In addition to being able to view MSIL, you can also view the C # form of the method by selecting Decompiler under the Tools menu. Change your choice under the Languages ​​menu, you can also view the method after being confined to Visual Basic .NET or Delphi. The following is the code generated by .Net Reflector: public void hashtableaddtest () {

Hashtable hashtable1;

Hashtable1 = new hashtable ();

Hashtable1.add ("key1", "value1");

Hashtable1.add ("key2", "value2");

Assert.Arequal ("Value1", Hashtable1 ["Key1"],

"WRONG OBJECT RETURNED!");

Assert.Arequal ("Value2", Hashtable1 ["Key2"],

"WRONG OBJECT RETURNED!");

}

The previous code looks like I actually written for this method. The following is the actual code in the assembly: public void hashtableaddtest ()

{

Hashtable ht = new hashtable ();

Ht.Add ("Key1", "Value1");

HT.Add ("Key2", "Value2");

AskERT.Areequal ("Value1", HT ["Key1"],

"WRONG OBJECT RETURNED!");

AskERT.Areequal ("Value2", HT ["Key2"],

"WRONG OBJECT RETURNED!");

} Although there are some small differences in the above code, they are functionally identical. Although this example is a good way to display actual code and anti-compile code, in my opinion, it does not mean the best use of .NET Reflector - Analysis .NET Framework assembly and method. The .NET framework provides many different ways to perform similar operations. For example, if you need to read a set of data from XML, there are a variety of methods that use XMLDocument, XPathnavigator or XmlReader to complete the work. By using the .Net Reflector, you can view what Microsoft uses what works when writing a data set, or seeing what works when they read data from the configuration file. .NET Reflector or an excellent way to understand the following best implementations: Create objects such as httphandlers or configuration handler, because you can understand how the Microsoft Workgroup actually generates these objects in the framework. .NET Reflector is written by Lutz Roeder, the download address is: http://www.aisto.com/roeder/dotnet Ndoc write code documentation is almost always a fearful task. What I said is not an early design document, or even more detailed design documents; I am talking about the various methods and properties on the record class. The NDOC tool can use reflection to analyze the assembly, and use XML generated from C # XML annotations to generate documentation for code. XML comments apply only to C #, but there is a Visual Studio .NET Power Toy called VBcommenter, which can do a similar job for Visual Basic .NET. In addition, the next version of Visual Studio will support XML annotations for more languages. When using NDOC, you are still writing code technology documents, but you have completed documentation in the process of writing code (in XML annotations), and this is easier to endure. When using NDOC, the first step is to open an XML annotation function for your assembly. Right-click the item and select Properties | Configuration Properties | Build, and enter the path to save the XML file in the XML Documentation File option. When the project is generated, an XML file is created, which contains all XML comments. Below is a method of writing a document in the NUnit example: ///

/// THIS TEST AddS a Number of Values ​​To The HashTable Collection

/// and the retrieves those value and checks if the match.

///

[TEST]

Public void hashtableaddtest ()

{

//Method Body Here

} The XML document information about this method will be extracted and saved in the XML file, as shown below:

this test add a number of values ​​to the Hashtable Collection

AND THEN RETRIEVES Those Values ​​and Checks if the match.

NDOC uses reflection to examine your assembly, then read XML in this document and match them. NDOC uses this data to create any number of different document formats, including HTML Help File (CHM). After generating an XML file, the next step is to load the assembly and the XML file into NDOC so that they can be processed. This work can be easily done by opening NDOC and clicking the Add button. After loading the assembly and XML file into NDOC and uses the available property range custom output, click the Generate button to start the process of generating document data. Using the default properties, NDOC can generate some very attractive and practical .html and .html and .chm files, which automatically completes the original very boring task in a quick and effective way. NDOC is an open source project, download address is: http: //ndoc.sourceforge.net/ Nant Nant is a .NET-based generating tool, different from the current version of Visual Studio .net, which makes your project creation The generation process is very easy. When you have a large number of developers engaged in a single project, you can't rely on a seat from a single user. You also don't want to manually generate this project regularly. You are more willing to create automatic generation processes running every night. Nant allows you to generate solutions, copy files, run NUnit test, send emails, and so on. Unfortunately, NANT lacks a beautiful graphical interface, but it does have a console application and XML file that can specify which tasks should be completed during the generation process. Note that MSBuild (New Generate Platform belonging to Visual Studio 2005) is prepared for each robust generation scheme and is driven in a similar manner based on XML-based project files. In this example, I will create a Nunit version file for the NUNITEXAMPLE solution created in front. First, I need to create an XML file with the .build extension, put it in my root directory, then add an XML declaration to the top of the file. The first tag I need to add to the file is Project tag:

The NUnit Example Project

The item standard is also used to set the project name, the default target, and the base directory. The Description tag is used to set a short description of the project. Next, I will add a Property tag that can be used to store the settings to a single location (then can access the location from any location in the file). In this example, I will create an attribute called debug, I can set it to True or false to reflect whether I want to compile the project under debug configuration. (Finally, this particular property does not really affect how to generate the project; it is just a variable you set, when you really determine how to generate the item, you will read the variable.) Next, I need to create a Target tag. . A project can contain multiple Targets specified at NANT runtime. If you do not specify a Target, use the default target (I set the target of the Project element). In this example, the default target is build. Let us observe the Target element, which will contain most of the generated information:

During the target element, I will set the name of the target to build and create a description of what works will be done. I will also create a CSC element that specifies the data that should be passed to the CSC C # compiler. Let's take a look at the CSC element:

Debug = "$ {debug}">

First, I have to set the Target of the CSC element. In this example, I will create a .dll file, so I set the target to library. Next, I have to set up the Output of the CSC element, which is the location where the .dll file will be created. Finally, I need to set the debug property that determines whether it is compiled in debugging. Because I created an attribute used to store this value in front, I can use the following string to access the value of this property: $ {debug}. The CSC element also contains some child elements. I need to create two elements: References elements will tell NANT which assemblies need to be referenced for the project, Sources elements tell NANT which files are to be included in the generation process. In this example, I reference the NUnit.framework.dll assembly and contain the HashTableTest.cs file. A complete generated file is displayed in Figure 8. (You usually have to create a clean target, used to delete the generated file, but for the sake of simplicity, I have omitted it.) To generate the file, I need to go to my project root (generated file bit here Position) and then execute nant.exe from this location. If the generation is successful, you can find a .dll and .pdb file in the bin directory of the application. Although using Nant is not as simple as in Visual Studio, it is still a very powerful tool that can be used to develop the generated process running according to the automatic plan. Nant also includes useful features, such as running unit testing or copying additional files (these features are not supported by the current Visual Studio generation process). Nant is an open source project, the download address is: http: //nant.sourceforge.net/ Conversion Tool I have placed two separate tools together under the title "Conversion Tool". These two tools are very simple, but it may be very useful. The first tool is an ASP.NET version converter that can be used to convert the version of the ASP.NET (virtual directory in it runs). The second tool is Visual Studio Converter, which can be used to convert project files from Visual Studio .NET 2002 to Visual Studio .NET 2003. When IIS processing request, it views the extension of the requested file, and then delegate the request to the ISAPI extension or handles the request based on the extension mapping of the Web site or virtual directory. This is the working mode of ASP.NET; will register extension mappings for all ASP.NET extensions and guide these extensions maps. This way is perfect, unless you install ASP.NET 1.1 - it will upgrade the extension map to the new version of ASPNET_ISAPI.dll. This will cause errors when the application generated on ASP.NET 1.0 is running. To resolve this issue, you can re-convert all extended mappings to the version of ASPNET_ISAPI.DLL, but because there are 18 extension mappings, it will be boring manually. This is the time when the ASP.NET version converter can work. Using this small utility, you can convert the version of the .NET framework used by any single ASP.NET application. Figure 9 ASP.NET Release Converter Figure 9 shows the actual ASP.NET version converter.

转载请注明原文地址:https://www.9cbs.com/read-55319.html

New Post(0)