Tutorials to .com

Tutorials to .com » Dotnet » Foundation » ASP.NET 2.0 compiler under the conditions

ASP.NET 2.0 compiler under the conditions

Print View , by: iSee ,Total views: 20 ,Word Count: 752 ,Date: Fri, 21 Aug 2009 Time: 9:59 AM

Web development in a single page of the functional test is too much trouble, from the Home user name, password, go after a number of operations before they can come to you want to test the page. (Actually, no matter what the development, testing a single function are very troublesome). With the attitude of caution, I like to write a few paragraphs of general test the first time, if every timestart to test the entire project is very economical alternative.

Solution I usually add a configuration used for testing by adding a "Test" compiler directives like, and then in the code, the number of test conditions, test methods put under the command. Team in the development of unit testing has not yet introduced the concept of like, I do not want to add a test item used in such a way to do this kind of thing. But as the Web under the individual circumstances Page so I do not know how the law should be. Therefore, before using or compile their own methods of instruction suchpoint.

(I used to write under a number of non-WEB when things also like to test methods and categories of their own writing in a document, then distinguished from the compiler command, to test directly in the development environment select "Test" of that configuration, and then start to test the TestDriven, do not start the whole project a lot of labor-saving machinery, TestDriven this thing is very effective.
If you are using c # for development, in the development environment, if the current conditions are not satisfied with the compiler when the code will be gray out those, and can be indented, is not impaired eyes)

But those tricks I in a little bit No matter under VS2005, and now WEB development with little distinction between the past. In the above areas can not findto add compiler directives, the development of non-WEB can still find places to add. , found that some things are set up to put in the Web.config, the conditions of the compiler of course no exception.

For example, would now like to add a "Test" command to compile the conditions. In the Web.config file, in <compilation> under this section by adding the following statement on it.

<compilers>

<compiler language = "vb"

type = "Microsoft.VisualBasic.VBCodeProvider, System, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = B77A5C561934E089"

extension = ". VB"

compilerOptions = "/ define: Debug = True / define: Trace = True / define: Test = True" />

<compiler language = "c #"

type = "Microsoft.CSharp.CSharpCodeProvider, System, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = B77A5C561934E089"

extension = ". cs"

compilerOptions = "/ d: DEBUG; TRACE; Test" />

</ compilers>

Is fatal, for each language should be added a <compiler>, of course, useless if the project to the appropriate language, also can be the rationale for it, can be removed. General C++ #, vb and more used to compare, I can only engage in two kinds of this.

Years after the Web.config settings do not have to be tested in each of the pages up the definition of compiler directives, but did not cool before, in the past directly in the IDE toolbar configuration options click on the line, and now insisted that thethings, but the main or inconvenient to switch. For example, I do not want in the "Test" under the conditions to start, I have to go to a section of Web.config in the above comment out things.
Is in accordance with the MSDN, the. Net 2.0 under, <compiler> of this element is deprecated, and I like this approach is not right.

http://lichdr.cnblogs.com/archive/2006/06/23/433964.html


.NET foundation Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.