mscorlib 4.0.0.0 System.Attribute System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=true, Inherited=false) System.Diagnostics.Conditional("CONTRACTS_FULL")

The following table shows the currently supported options.

Category

Setting

Value/effect

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:

`[assembly:ContractOption("runtime", "checking", false)]`

To turn run-time contract checking on for a specific type:

`[ContractOption("runtime", "checking", true)] class TypeWithRuntimeChecking { ...`

To turn run-time checking off for a specific method:

`// 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(...) { ... } }`

Enables you to set contract and tool options at assembly, type, or method granularity.

- Constructor
  4.0.0.0
  To be added.

  Initializes a new instance of the class by using the provided category, setting, and enable/disable value.

  The category for the option to be set.
  The option setting.
  true to enable the option; false to disable the option.
- Constructor
  4.0.0.0

  There are only two category/setting options, and they can be set by either of the constructor overloads. You can use this overload with the same settings as the overload by specifying "true" or "false" in string format; for example:

  [ContractOption("contract", "inheritance", “false”)] class MyConcurrentList<T> : IList<T> { ... }

  Initializes a new instance of the class by using the provided category, setting, and value.

  The category of the option to be set.
  The option setting.
  The value for the setting.
- Property
  4.0.0.0
  System.String To be added. To be added.

  Gets the category of the option.

- Property
  4.0.0.0
  System.Boolean To be added. To be added.

  Determines if an option is enabled.

- Property
  4.0.0.0
  System.String To be added. To be added.

  Gets the setting for the option.

- Property
  4.0.0.0
  System.String To be added. To be added.

  Gets the value for the option.