0

I am working in Visual Studio 2013. I have written a console application that generates text. I call that application in the post build of another (larger winforms) application. I have been able to configure my output string in such a way that the output of my console application is picked up by Visual Studio, and is displayed in the error or warning list. Hence if I call the console program in the other projects post build, in the warning list of that project, I can see my output of my console application.

Console.WriteLine(String.Format("{0}({1},{2},{1},{3}): {4}: string should be translated. {5}",    
                 filefullpathname,
                 linenumber,
                 indexQuote + 2, // index of start of string
                 nextQuote + 1,
                 TreatAs,
                 line.Trim()));

In the variable TreatAs I can put the text "warning" and I can see the warning in my error list window in Visual studio. But can I use a custom warning number like "warning CS9999", so that I could use the following code to suppress my warning:

#pragma warning disable 9999

Just using a random number like 9999 gives a message '9999 is not a valid warning number' so I cannot just pick any number. I also tried just borrowing a number from another warning but that did not work either.

Hence: Are there warning numbers which you can use as custom build warning error numbers?

JaJa
  • 411
  • 2
  • 13
  • The pragma stops the compiler from *generating* the warning - it's not part of the Visual Studio error list filtering. You could *try* the "Suppress Warnings" part of the project configuration, but I don't know whether that would have an effect. – Jon Skeet Apr 30 '14 at 14:26
  • Thank you. I am not sure if I understand you correctly. I want to suppress the warning only for certain files. If I want my own generated warning to be suppressed for the whole project, then I would not generate it in the post build. Hence I dont think it is the effect I want. An alternative is, writing some comment in the source file, so that the console application that is called in the post build, wont generate the error. (Then that would be like #pragma disable would work for normal code, right?) – JaJa Apr 30 '14 at 14:32
  • It's not really clear what you're doing, to be honest. Your console app isn't being executed on a per-file basis, so how would you expect warnings to be suppressed on a per file basis? Typically custom errors like this *are* suppressed via things like comments, to be honest. – Jon Skeet Apr 30 '14 at 14:36
  • You could write logic in the console app to not generate the error when you don't want it generated – reggaeguitar Apr 30 '14 at 14:43
  • Ok. I understand I tried the wrong way to resolve this. I will use a comment and read that in my console application to suppress the error per file. I already did that actually per line. You are right the solution I was thinking of, cannot work. Sorry to have bothered you with my stupid question. ;-) – JaJa May 01 '14 at 05:52

0 Answers0