System.Diagnostics.Contracts 命名空間

System.Diagnostics.Contracts 命名空間包含代表程式合約的靜態類別,例如前置條件、後置條件及非變異。 The System.Diagnostics.Contracts namespace contains static classes for representing program contracts such as preconditions, postconditions, and invariants.

類別

Contract

包含表示程式合約的靜態方法,例如前置條件、後置條件及物件非變異。Contains static methods for representing program contracts such as preconditions, postconditions, and object invariants.

ContractAbbreviatorAttribute

定義可以取代完整合約語法的縮寫。Defines abbreviations that you can use in place of the full contract syntax.

ContractArgumentValidatorAttribute

可讓您將舊版 if-then-throw 程式碼分成不同的方法以供重複使用,並讓您完整控制擲回的例外狀況和引數。Enables the factoring of legacy if-then-throw code into separate methods for reuse, and provides full control over thrown exceptions and arguments.

ContractClassAttribute

指定包含此類型程式碼合約的個別類型。Specifies that a separate type contains the code contracts for this type.

ContractClassForAttribute

指定類別為類型的合約。Specifies that a class is a contract for a type.

ContractFailedEventArgs

提供 ContractFailed 事件的方法與資料。Provides methods and data for the ContractFailed event.

ContractInvariantMethodAttribute

標記方法為類別的非變異方法。Marks a method as being the invariant method for a class.

ContractOptionAttribute

可讓您以組件、型別或方法的資料粒度設定合約及工具選項。Enables you to set contract and tool options at assembly, type, or method granularity.

ContractPublicPropertyNameAttribute

指定當欄位的可視性比方法還低時,可在方法合約中使用的欄位。Specifies that a field can be used in method contracts when the field has less visibility than the method.

ContractReferenceAssemblyAttribute

指定組件為包含合約的參考組件。Specifies that an assembly is a reference assembly that contains contracts.

ContractRuntimeIgnoredAttribute

識別沒有任何執行階段行為的成員。Identifies a member that has no run-time behavior.

ContractVerificationAttribute

指示分析工具假設組件、類型或成員的正確性,而不執行靜態驗證。Instructs analysis tools to assume the correctness of an assembly, type, or member without performing static verification.

PureAttribute

表示類型或方法是純粹的,也就是它不會進行任何可見的狀態變更。Indicates that a type or method is pure, that is, it does not make any visible state changes.

列舉

ContractFailureKind

指定失敗的合約類型。Specifies the type of contract that failed.