See Also: ContractOptionAttribute Members
The following table shows the currently supported options.
| contract |
inheritance |
true to turn contract inheritance on; false to turn it off. The default is true. |
| runtime |
checking |
true to turn run-time checking on; false to turn it off. The default is true. |
You can use this attribute as illustrated in the following examples.
To turn off run-time checking for the entire assembly:
Example
[assembly:ContractOption("runtime", "checking", false)]To turn run-time contract checking on for a specific type:
Example
[ContractOption("runtime", "checking", true)]
class TypeWithRuntimeChecking {
...
To turn run-time checking off for a specific method:
Example
// Turn off all contract inheritance from interface IList<T>
[ContractOption("contract", "inheritance", false)]
class MyConcurrentList<T> : IList<T> {
...
}
[ContractOption("runtime", "checking", false)]
public override MyMethod(int x) {
// no inherited contracts checked at runtime,
// no invariants checked at runtime.
...
}
[ContractOption("runtime", "checking", false)]
public void MethodWithoutRuntimeChecking(...) {
...
}
}