views:

88

answers:

1

I have read the MSDN Page on how to suppress messages. I am unable to supress warnings for VS2008.

I have tried the following instructions listed:

  1. In the Error List, select the warning or warnings to suppress. Multiple warnings can be selected at the same time.

  2. Right-click the warning, point to Suppress Message(s), and click either In Source or In Project Suppression File.

  3. The specific warning is suppressed, and the warning appears in the Error List window with a strikethrough.

However, when I right click in the 'Error List' I only get the following options:

  • Sort By
  • Show Columns
  • Show Error Help
  • Copy
  • Previous Error
  • Next Error

Why does Visual Studios 2008 for VB.net not display 'Suppress Messages'?

I cannot generate the following suppressing messages:

<Scope:SuppressMessage("Rule Category", "Rule Id", "Justification", "MessageId", Scope = "Scope", Target = "Target")>

The problem was I had a series of parallel tasks that were dependent on check boxes. I wanted each task to to run simultaneously and then join back. I overcame the warning by using a callback method that decremented until all the call backs completed.

ie (from memory):

chkbox1.enable = false
chkbox2.enable = false
dim dlgChkbox1 as Action = addressof Task1
dim dlgChkbox2 as Action = addressof Task2
...
if chkbox1.checked = true then
   result = dlgChkbox1.BeginInvoke(nothing,nothing)
end if
if chkbox2.checked = true then
   result = dlgChkbox2.BeginInvoke(nothing,nothing)
end if
...
if chkbox1.checked = true then
    dlgChkbox1.EndInvoke()
end if
if chkbox1.checked = true then
    dlgChkbox2.EndInvoke()
end if
...
chkBox1.enable = true
chkBox2.enable = true

The warning was an Uninitialized Variable. Which was not the case as it was dependent on identical if-statements. I opted to use a callback method instead, which turned out to be a better alternative and did not lock up the GUI.

+2  A: 

Wrong MSDN page. That one talks about suppressing warnings produced by the Code Analysis tool. Very different animal from the VB.NET compiler.

To suppress compiler warnings, use Project + Properties, Compile tab, Warning configurations section. Locate the specific warning message you want to disable, change the notification setting from "Warning" to "None". The "Disable all warnings" checkbox is the big hammer solution.

Hans Passant
I dont want to suppress all warnings for a specific type just an instance where I know it is safe. Is there similar to #pragma warning disable / #pragma warning restore?
Shiftbit
There isn't. Post a snippet of the code if you want help with an alternative.
Hans Passant
@Hans Passant: Thank you for your help. I reworked the problem. I think a #pramga or metadata tag would be a nice addition to VB.
Shiftbit