Contract Methods

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Include Protected Members
Include Inherited Members

Include Silverlight Members
Include Silverlight for Windows Phone Members
Include XNA Framework Members

The Contract type exposes the following members.

Methods

  Name Description
Public methodStatic member Assert(Boolean) Checks for a condition; if the condition is false, follows the escalation policy set for the analyzer.
Public methodStatic member Assert(Boolean, String) Checks for a condition; if the condition is false, follows the escalation policy set by the analyzer and displays the specified message.
Public methodStatic member Assume(Boolean) Instructs code analysis tools to assume that the specified condition is true, even if it cannot be statically proven to always be true.
Public methodStatic member Assume(Boolean, String) Instructs code analysis tools to assume that a condition is true, even if it cannot be statically proven to always be true, and displays a message if the assumption fails.
Public methodStatic member EndContractBlock Marks the end of the contract section when a method's contracts contain only preconditions in the if-then-throw form.
Public methodStatic member Ensures(Boolean) Specifies a postcondition contract for the enclosing method or property.
Public methodStatic member Ensures(Boolean, String) Specifies a postcondition contract for a provided exit condition and a message to display if the condition is false.
Public methodStatic member EnsuresOnThrow<TException>(Boolean) Specifies a postcondition contract for the enclosing method or property, based on the provided exception and condition.
Public methodStatic member EnsuresOnThrow<TException>(Boolean, String) Specifies a postcondition contract and a message to display if the condition is false for the enclosing method or property, based on the provided exception and condition.
Public methodStatic member Exists(Int32, Int32, Predicate<Int32>) Determines whether a specified test is true for any integer within a range of integers.
Public methodStatic member Exists<T>(IEnumerable<T>, Predicate<T>) Determines whether an element within a collection of elements exists within a function.
Public methodStatic member ForAll(Int32, Int32, Predicate<Int32>) Determines whether a particular condition is valid for all integers in a specified range.
Public methodStatic member ForAll<T>(IEnumerable<T>, Predicate<T>) Determines whether all the elements in a collection exist within a function.
Public methodStatic member Invariant(Boolean) Specifies an invariant contract for the enclosing class.
Public methodStatic member Invariant(Boolean, String) Specifies an invariant contract for the enclosing class, and displays a message if the condition for the contract fails.
Public methodStatic member OldValue<T> Represents values as they were at the start of a method or property.
Public methodStatic member Requires(Boolean) Specifies a precondition contract for the enclosing method or property.
Public methodStatic member Requires(Boolean, String) Specifies a precondition contract for the enclosing method or property, and displays a message if the condition for the contract fails.
Public methodStatic member Requires<TException>(Boolean) Specifies a precondition contract for the enclosing method or property, and throws an exception if the condition for the contract fails.
Public methodStatic member Requires<TException>(Boolean, String) Specifies a precondition contract for the enclosing method or property, and throws an exception with the provided message if the condition for the contract fails.
Public methodStatic member Result<T> Represents the return value of a method or property.
Public methodStatic member ValueAtReturn<T> Represents the final (output) value of an out parameter when returning from a method.

Top