asp.net 2.0 under the conditions of compilation _ Practical Skills

Source: Internet
Author: User

In the Web development test the function of a single page is too troublesome, from the home page user name, password go in, after some operation before you can come to the test of the page. (In fact, no matter what the development, testing a single function is very cumbersome). With a cautious attitude, I generally like to write a few paragraphs of the test once, if every time selectmen start the whole project to testing is obviously very economic practice.

I typically add a configuration for testing in solution, add a compile instruction such as "test", and then put some test conditions, test methods, into this instruction in the code. When the development team hasn't introduced concepts like unit testing, I don't want to do this with a new test project. And for a single page like the one on the web, I don't know how to do it. So it is better to use the previous compilation instructions This method comparison of the familiar points.

(I used to write some things under the web, also like to write the test method and the class itself in a file, and then the compilation of instructions to separate, if you want to test, directly in the development environment to select the "test" that configuration, and then start Testdriven to test it, Not to start the whole project on the machine much more labor, testdriven this thing is very useful.
If you are using C # for development, in the development environment, if the current compilation conditions are not satisfied, the code will be grayed out, and can be indented, no obstacle to the eyes.

But my tricks, under the VS2005 a little bit of use, now web development is a little different from the previous. You can't find a place to find it. New compilation directives, non-web development can still find places to add. Toss for a long time, found that some of the settings are now put into the web.config, conditional compilation of course is no exception.

For example, now you need to add a conditional compilation instruction for "Test". In the Web.config file, add the following statement to the <compilation> section below.

<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>

Very lethal, to each language must add a <compiler>, of course, if the project does not use the corresponding language, you can ignore it, you can delete. General C #, VB used more, I only engaged in these two kinds.

Web.config after setting up in every need to test the page to define the compilation instructions, but still no previous cool, the previous directly in the IDE toolbar to select the configuration on the line, now obstinately to write so many things, and mainly is not convenient to switch. For example, if I don't start under Test, I have to go to the Web.config to comment out the above paragraph.
According to MSDN, under. Net 2.0,<compiler> This element is deprecated, and I don't seem to be doing it right.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.