Code Contracts + Code Analysis

前端 未结 2 2187
攒了一身酷
攒了一身酷 2021-02-05 06:56

I think about starting to use Code Contracts in my code base.

I already use Code Analysis with all rules enabled and a goal of zero warnings.

However, when using

2条回答
  •  遇见更好的自我
    2021-02-05 07:50

    To solve this problem, the following steps need to be performed:

    1. Disable CA1062 in Code Analysis to get rid of the warning from Code Analysis. There is currently no way to make Code Analysis understand Contract.Requires.
    2. Enable "Perform Static Contract Checking" in the Code Contracts pane of the project.
    3. Enable "Implicit Non-Null Obligations"
    4. Set Warning Level to "hi" (important, that was what I was missing!)

    Step 1 gets rid of the CA warning, steps 2 to 4 enable a warning from Code Contracts that's at least equivalent.

提交回复
热议问题