Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I heard that we have to build with the highhest warning level.

Is it true? why?

And how to change default .NET warning level?

share|improve this question
1  
The question is also completely subjective. If you think you need all the warnings then have them on, otherwise don't. You could go further and install ReSharper - that will give you hundreds more warnings if warnings are what you like. –  James Gaunt Jun 6 '11 at 8:48
    
@James, I'm not looking for warnings, I heard it from a real expert and he recommend me to resolve them as much as possible, but it seems wierd to me so that I shared it here with you. –  Mohammad Nezhad Jun 6 '11 at 8:50
    
Personally, I enable all warnings AND set "Treat warnings as errors" in VS. And I have Resharper too. Most of the time, warnings are actually errors or sloppy code that needs to be fixed. This setup doesn't allow me to skip fixing. –  Nevermind Jun 6 '11 at 9:33
1  
It also worth mentioning the VS static analysis and code contracts - it will add some more warnings. –  SK-logic Jun 6 '11 at 10:00
1  
For me this is true for any language, not just about .NET. Configure the system to show all warnings, and you choose to treat or ignore them. But at least you'll see them. –  Carlos Campderrós Jun 6 '11 at 13:18
add comment

migrated from stackoverflow.com Jun 6 '11 at 9:00

This question came from our site for professional and enthusiast programmers.

2 Answers

You don't have to, but it is a good idea to build with the highest warning level. Why? Warnings are potential problems with your code - things you might have done wrong, badly or in a way that is likely to cause problems.

Turning on the warnings at the highest level will highlight these problems, allowing you to fix them early, rather than let them become potential bugs at a later date. Plus, you'll learn good programming practice as you compile - improving your coding as you go.

Edit: In Visual Studio 2010, you can change the warning level for a project by right-clicking on it, going to its properties page and then setting warning level to 4 on its Build tab. If you also tick 'Warnings as errors', any warnings will break your build - so you'll have to fix them.

share|improve this answer
2  
Well said. Which also indicates that it's a "red flag" if developers ignore warnings entirely because "it still compiles". –  Wayne M Jun 6 '11 at 12:30
    
i think warnings as errors is a little extreme, especially when building web apps and vs complains about css it doesn't understand. –  Steve Jun 6 '11 at 16:57
    
@Steve: Yes - it doesn't suit all circumstances. –  Jackson Pope Jun 6 '11 at 17:01
add comment

It helps you ensure you check all of the warnings.

These warnings may be change in the future version (for instance, their namespace may be change)

Also this maybe face you with an issue in a specific field.

You have to know all of your application warning and resolve them ASAP.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.