Skip to content

Code contracts are .NET Framework only #25619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/framework/debug-trace-profile/code-contracts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: "Code Contracts"
description: Explore code contracts, which provide a way to specify preconditions, postconditions, and object invariants in your .NET code.
titleSuffix: .NET Framework
description: "Explore code contracts, which provide a way to specify preconditions, postconditions, and object invariants in your .NET Framework code."
ms.date: "09/05/2018"
dev_langs:
- "csharp"
Expand All @@ -9,9 +10,12 @@ helpviewer_keywords:
- "Code contracts"
ms.assetid: 84526045-496f-489d-8517-a258cf76f040
---
# Code Contracts
# Code contracts (.NET Framework)

Code contracts provide a way to specify preconditions, postconditions, and object invariants in your code. Preconditions are requirements that must be met when entering a method or property. Postconditions describe expectations at the time the method or property code exits. Object invariants describe the expected state for a class that is in a good state.
Code contracts provide a way to specify preconditions, postconditions, and object invariants in .NET Framework code. Preconditions are requirements that must be met when entering a method or property. Postconditions describe expectations at the time the method or property code exits. Object invariants describe the expected state for a class that is in a good state.

> [!NOTE]
> Code contracts aren't supported in .NET 5+ (including .NET Core versions). Consider using [Nullable reference types](../../csharp/nullable-references.md) instead.

Code contracts include classes for marking your code, a static analyzer for compile-time analysis, and a runtime analyzer. The classes for code contracts can be found in the <xref:System.Diagnostics.Contracts> namespace.

Expand Down