|
1 | 1 | CodeContracts.MSBuild |
2 | 2 | ===================== |
3 | 3 |
|
4 | | -Standalone MSBuild integration for CodeContracts (by Microsoft Research) |
| 4 | +Standalone MSBuild integration for [Microsoft CodeContracts](https://github.com/microsoft/codecontracts) (by Microsoft Research). |
| 5 | + |
| 6 | +## Installation |
| 7 | + |
| 8 | +Simply add `CodeContracts.MSBuild` nuget to projects that use Code Contracts. |
| 9 | + |
| 10 | +From package manager: |
| 11 | + |
| 12 | +``` |
| 13 | +Install-Package CodeContracts.MSBuild |
| 14 | +``` |
| 15 | + |
| 16 | +From .Net CLI: |
| 17 | + |
| 18 | +``` |
| 19 | +dotnet add package CodeContracts.MSBuild |
| 20 | +``` |
| 21 | + |
| 22 | +## Settings |
| 23 | + |
| 24 | +### `DontOverrideCodeContractsInstallDir`, `CodeContractsInstallDir` |
| 25 | + |
| 26 | +By default `CodeContracts.MSBuild` uses CodeContracts version that is bundled with this package. |
| 27 | + |
| 28 | +However, if you want to use custom CodeContracts installation, |
| 29 | +you can define the following MSBuild properties in your project file: |
| 30 | + |
| 31 | +```xml |
| 32 | +<PropertyGroup> |
| 33 | + <DontOverrideCodeContractsInstallDir>true<DontOverrideCodeContractsInstallDir> |
| 34 | + <CodeContractsInstallDir>your_custom_codecontracts_install_dir\</CodeContractsInstallDir> |
| 35 | +</PropertyGroup> |
| 36 | +``` |
| 37 | + |
| 38 | +### `CodeContracts*` |
| 39 | + |
| 40 | +`CodeContracts.MSBuild` defines a bunch of default properties that are used by Microsoft CodeContracts. |
| 41 | +Please refer to CodeContracts for meaning of these options. |
| 42 | + |
| 43 | +| Property | Default value | Description | |
| 44 | +|----------|---------------|-------------| |
| 45 | +| **Runtime checking** | |
| 46 | +| `CodeContractsEnableRuntimeChecking` | `False` | Runtime checking. If `False`, whole section is irrelevant. | |
| 47 | +| `CodeContractsAssemblyMode` | `1` | Assembly mode, `1` = standard, `2` = advanced. | |
| 48 | +| `CodeContractsRuntimeCheckingLevel` | `Full` | Level: `Full`, `Pre and Post`, `Preconditions`, `ReleaseRequires`, `None` | |
| 49 | +| `CodeContractsRuntimeOnlyPublicSurface` | `False` | Only public surface contracts | |
| 50 | +| `CodeContractsRuntimeThrowOnFailure` | `False` | Assert on contract failure | |
| 51 | +| `CodeContractsRuntimeCallSiteRequires` | `False` | Call-site requires checking | `CodeContractsRuntimeSkipQuantifiers` | `False` | Skip quantifiers | |
| 52 | +| `CodeContractsCustomRewriterAssembly` | *empty* | Custom rewriter methods / Assembly | |
| 53 | +| `CodeContractsCustomRewriterClass` | *empty* | Custom rewriter methods / Class | |
| 54 | +| **Static checking** | |
| 55 | +| `CodeContractsRunCodeAnalysis` | `True` | Static checking. If `False`, whole section is irrelevant. | |
| 56 | +| `CodeContractsNonNullObligations` | `True` | Check non-null | |
| 57 | +| `CodeContractsEnumObligations` | `True` | Check enum values | |
| 58 | +| `CodeContractsRedundantAssumptions` | `True` | Check redundant assume | |
| 59 | +| `CodeContractsSuggestAssumptions` | `False` | Show entry assumptions | |
| 60 | +| `CodeContractsSuggestRequires` | `False` | Suggest requires | |
| 61 | +| `CodeContractsAssertsToContractsCheckBox` | `True` | Suggest asserts to contracts | |
| 62 | +| `CodeContractsInferRequires` | `True` | Infer requires | |
| 63 | +| `CodeContractsInferEnsures` | `False` | Infer ensures | |
| 64 | +| `CodeContractsArithmeticObligations` | `True` | Check arithmetic | |
| 65 | +| `CodeContractsMissingPublicRequiresAsWarnings` | `True` | Check missing public requires | |
| 66 | +| `CodeContractsRedundantTests` | `True` | Check redundant conditionals | |
| 67 | +| `CodeContractsSuggestAssumptionsForCallees` | `False`| Show external assumptions | |
| 68 | +| `CodeContractsSuggestReadonly` | `True`| Suggest readonly fields | |
| 69 | +| `CodeContractsNecessaryEnsures` | `True` | Suggest necessary ensures | |
| 70 | +| `CodeContractsInferObjectInvariants` | `False` | Infer invariants for readonly | |
| 71 | +| `CodeContractsInferEnsuresAutoProperties` | `True` | Infer ensures for autoproperties | |
| 72 | +| `CodeContractsFailBuildOnWarnings` | `False` | Fail build on warnings | |
| 73 | +| `CodeContractsBoundsObligations` | `True` | Check array bounds | |
| 74 | +| `CodeContractsMissingPublicEnsuresAsWarnings` | `False` | Check missing public ensures | |
| 75 | +| `CodeContractsSuggestObjectInvariants` | `False` | Suggest object invariants | |
| 76 | +| **Misc** |
| 77 | +| `CodeContractsCacheAnalysisResults` | `True` | Cache results | |
| 78 | +| `CodeContractsSQLServerOption` | *empty* | SQL Server | |
| 79 | +| `CodeContractsSkipAnalysisIfCannotConnectToCache` | `False` | Skip the analysis if cannot connect to cache | |
| 80 | +| `CodeContractsAnalysisWarningLevel` | `0` | Warning level: `0`, `1, `2`, `3` | |
| 81 | +| `CodeContractsBeingOptimisticOnExternal` | `True` | Be optimistic on external API | |
| 82 | +| `CodeContractsUseBaseLine` | `False` | Baseline | |
| 83 | +| `CodeContractsBaseLineFile`| *empty* | Baseline file | |
| 84 | +| `CodeContractsReferenceAssembly` | `Build` | Contract reference assembly | |
| 85 | +| `CodeContractsEmitXMLDocs` | `False` | Emit contracts into XML doc file | |
| 86 | +| **Advanced options** | |
| 87 | +| `CodeContractsLibPaths` | *empty* | Extra contract library paths | |
| 88 | +| `CodeContractsExtraRewriteOptions` | *empty* | Extra runtime checker options | |
| 89 | +| `CodeContractsExtraAnalysisOptions` | *empty* | Extra static checker options | |
0 commit comments