System.Diagnostics.Contracts.Contract.EndContractBlock Method

Marks the end of the contract section when a method's contracts contain only preconditions in the if-then-throw form.

Syntax

[System.Diagnostics.Conditional("CONTRACTS_FULL")]
[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)]
public static void EndContractBlock ()

Remarks

Most code already contains some parameter validation in the form of if-then-throw code. The contract tools recognize if-then-throw statements as preconditions when the statements appear first inside a method, and the entire set of such statements is followed by an explicit System.Diagnostics.Contracts.Contract method call, such as a erload:System.Diagnostics.Contracts.Contract.Requires, erload:System.Diagnostics.Contracts.Contract.Ensures, erload:System.Diagnostics.Contracts.Contract.EnsuresOnThrow, or Contract.EndContractBlock.

When if-then-throw statements appear in this form, the contract tools recognize them as legacy-require statements. The Contract.EndContractBlock form is used only if no other contracts follow the if-then-throw sequences, but they should still be tagged as legacy-requires.

Requirements

Namespace: System.Diagnostics.Contracts
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 4.0.0.0