Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find 'masked' assertions in MS Code Contracts

I have the following Message-level entry in my Error List from CodeContracts:

CodeContracts: Checked 410 assertions: 404 correct (6 masked)

I can't figure out:

  1. What masked assertions are
  2. How to locate the 6 that it mentions
  3. Whether or not I should be concerned about them

Sorry for not posting code... I have no idea how to recreate this in a small sample :)

Many thanks

like image 811
Adam Brown Avatar asked Apr 06 '12 00:04

Adam Brown


2 Answers

It's simple, in your project properties>Code Contracts>Static Checking> put the warning at "hi".

Now ccCheck made more warning.

Bye.

like image 76
S DELAPORTE Avatar answered Nov 04 '22 00:11

S DELAPORTE


These seem to be assertions that are masked by virtue of their inclusion in the "baseline" file. From the documentation (emphasis mine):

6.6.8 Baseline

Bringing an existing code base to a point where the verier emits only a few warnings is dicult and time consuming, as it requires adding numerous contracts. To make it easier to use contracts on existing code bases, and to focus warnings introduced by new code or code changes, the Baseline functionality can be used.

To use the baseline functionality, check the box labelled Baseline and provide a file name to store the baseline in. The path is relative to the project output directory. When the analysis is run and the baseline file does not exist, the baseline is created. During this run, all warnings are shown in the output and stored in the baseline file as XML.

When the analysis is run and the baseline file exists, then the baseline acts as a filter and warnings already found in the baseline are not shown again. New warnings are shown and stored in a file called <baseline>.new, where <baseline> is the file name of the baseline file. Since the files are stored as textual XML, it is possible to edit them and to add additional failures to the baseline. The format does not depend on method ordering and additional XML tags for grouping can be introduced freely.

I was wondering about the "masked" messages, too; I turned off the "baseline" option, and they no longer appeared. The answer to your second question therefore seems to be "clear the 'baseline' check box."

As to whether you should be concerned about them, I would say, yes, you should.

like image 35
phoog Avatar answered Nov 04 '22 01:11

phoog