Warning MSB3042 : How To suppress?

Our company writes a lot of tests (test driven environment)

In 2.0 we are now receiving the following warnings for existing code

Warning 8 A namespace or class definition was found within a conditional compilation directive in the file "TestForm.cs". This may lead to an incorrect choice for the manifest resource name for resource "GUI\Grid\Internal\Testing\TestForm.resx". ZArchitecture

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.CSharp.targets : warning MSB3042: A namespace or class definition was found within a conditional compilation directive in the file "TestForm.cs". This may lead to an incorrect choice for the manifest resource name for resource "GUI\Grid\Internal\Testing\TestForm.resx".

The sample syntax is as shown

using System;

namespace Enterprise.ZArchitecture

{

#if DEBUG

public class TestForm : Enterprise.Core.Forms.ODesignableForm

blah blah

How can these warnings be suppressed so we can get back to a zero warning tolerance policy



Answer this question

Warning MSB3042 : How To suppress?

  • Stephan123

    How about:


    #pragma warning disable 3042



  • Artashes

    Rather than conditionally compiling the tests only under debug (which means you never unit test the release code) consider having a separate assembly for the unit tests. It means it's harder to test internal members, although you can use reflection if you need to.



  • tomjanssen

    Thanks for the response.

    We build from both command line (have written a cool multithreaded build tool) and from the IDE. Our build tool already has filters so that presents no problem to me.

    The main problem is through the IDE - developers have stopped displaying warnings and have started checking in bad code.


  • VanDamMan

    Hi,

    This is one of the MSBuild boffins

    Are you building this in the IDE or the command line If you are building in the command line, the only option that we came about when speaking within the MSBuild Team is that you can write a custom logger (perhaps derive from ConsoleLogger) that filters out the required warning and logs other information that you care about.

    I understand that this is more work than you would hope for, and that this sort of stuff should be supported out of the box. The last thing you want to do when building code is to understand how to write a logger so you can filter stuff out - but this seems to be a tricky situation and a workable workaround if you are building from the command line.

    I will log a bug and see if we can have a noWarn kind of mechanism, similar to the compilers.

    Hope this helps.

    Faisal Mohamood | Program Manager | MSBuild


  • TheMax

    This would work , but just having migrated 4.5 million lines of code and 300 dlls it seems a bit steep to have to extract 2 million lines of tests and use lots of reflection (and it would be huge amounts).

    I'm sure an MSBuild boffin would have the answer for the right price :)


  • susan_newyork

    No, as MSB3042 is not a csharp compiler warning (rather an MS Build warning) the compiler then returns the following

    Warning 1 '3042' is not a valid warning number C:\enterprise\ZArchitecture\GUI\Controls\ZIsVisibleForBindingTestCase.cs 7 25 ZArchitecture


  • Warning MSB3042 : How To suppress?