locked
How to suppress enum warnings RRS feed

  • Question

  • Hi

    I want to suppress some enum warnings from static code checker like:

     CodeContracts: The assigned value may not be in the range defined for this enum value

    What is the CCxxxx code nummer for this, because it's not shown in Visual Studio Error List and I want to use the SuppressMessage attribute like:

    [SuppressMessage("Microsoft.Contracts", "CC1055", Justification = "Check performed in DelegateTo")]

    Kind regards

    Michael

    Wednesday, July 17, 2013 9:10 AM

Answers

  • Hi,

    In your project's properties window, select the Code Contracts tab and enter -outputwarnmasks into the Extra Static Checker Options field, including the preceding hyphen.  Then after building, check the Output window for the SuppressMessage attribute that you'll need.

    Note, however, that there might not actually be a way to suppress the particular warning that you want to suppress.

    - Dave


    http://davesexton.com/blog

    Wednesday, July 17, 2013 3:00 PM

All replies

  • Hi,

    In your project's properties window, select the Code Contracts tab and enter -outputwarnmasks into the Extra Static Checker Options field, including the preceding hyphen.  Then after building, check the Output window for the SuppressMessage attribute that you'll need.

    Note, however, that there might not actually be a way to suppress the particular warning that you want to suppress.

    - Dave


    http://davesexton.com/blog

    Wednesday, July 17, 2013 3:00 PM
  • Thanks Dave,

    this option produces a lot of output you have to search for the right output.

    This helped, but is a bit ugly:

    
    [SuppressMessage("Microsoft.Contracts", "Enum-20-0", Justification = "Reviewed, Enum handling is ok.")]
    [SuppressMessage("Microsoft.Contracts", "Enum-301-0", Justification = "Reviewed, Enum handling is ok.")]
    [SuppressMessage("Microsoft.Contracts", "Enum-78-0", Justification = "Reviewed, Enum handling is ok.")]

    Kind regards

    Michael

    Thursday, July 18, 2013 7:35 AM