TedToolkit.Annotations.Documentations
2026.7.16.3
dotnet add package TedToolkit.Annotations.Documentations --version 2026.7.16.3
NuGet\Install-Package TedToolkit.Annotations.Documentations -Version 2026.7.16.3
<PackageReference Include="TedToolkit.Annotations.Documentations" Version="2026.7.16.3" />
<PackageVersion Include="TedToolkit.Annotations.Documentations" Version="2026.7.16.3" />
<PackageReference Include="TedToolkit.Annotations.Documentations" />
paket add TedToolkit.Annotations.Documentations --version 2026.7.16.3
#r "nuget: TedToolkit.Annotations.Documentations, 2026.7.16.3"
#:package TedToolkit.Annotations.Documentations@2026.7.16.3
#addin nuget:?package=TedToolkit.Annotations.Documentations&version=2026.7.16.3
#tool nuget:?package=TedToolkit.Annotations.Documentations&version=2026.7.16.3
TedToolkit.Annotations.Documentations
Express API contracts, operational behavior, specifications, and design rationale as structured C# attributes. These annotations complement XML documentation; they do not change runtime behavior.
Install
dotnet add package TedToolkit.Annotations.Documentations
The package includes an analyzer and a code fix that can generate XML <exception> documentation from typed preconditions.
Use
Apply annotations to the API surface they describe:
using TedToolkit.Annotations.Documentations;
[ThreadSafety(ThreadSafetyKind.THREAD_SAFE, "All state is protected by _gate.")]
public sealed class Counter
{
[Precondition<ArgumentOutOfRangeException>("amount must be positive.")]
[Postcondition("The returned value is greater than or equal to amount.")]
[SideEffect(SideEffectKind.INSTANCE_STATE_MUTATION, "Increments the counter.")]
public int Add(int amount) => 0;
}
The main groups are:
Attribute reference
| Attribute | Effect | Use it when |
|---|---|---|
Precondition / Precondition<TException> |
Records a condition callers must satisfy; the generic form identifies the exception thrown when it is violated. | A method or constructor requires a non-obvious argument, state, or environment condition. |
Postcondition |
Records a condition guaranteed after successful completion. | Callers need to rely on a return value or state guarantee not evident from the signature. |
Invariant |
Records a condition that remains true for an annotated type or member. | A persistent state rule must be preserved across maintenance. |
ThreadSafety |
Records thread-safety guarantees or synchronization requirements. | Concurrent use is supported, conditional, requires caller synchronization, or is unsupported. |
ThreadAffinity |
Records the required thread or synchronization context. | Code must run on a UI thread, a dispatcher, or another specific context. |
MayBlock |
Records that an operation can block and why. | An API can wait on I/O, locks, processes, user input, or another blocking source. |
SideEffect |
Records an observable effect, optionally with a standard category. | An API mutates state, performs I/O, publishes a notification, invokes a callback, or changes resource lifetime. |
Idempotent |
Records that repeated calls with the same effective input are safe. | Retrying an operation does not add a further observable effect. |
BehaviorCase / BehaviorCase<TException> |
Records an input condition and the expected result, with optional test coverage and exception type. | A method has important branches that should remain explicit and testable. |
StateTransition |
Records the required state before and guaranteed state after success. | An API advances an object, workflow, or resource through named states. |
DesignDecision |
Records a stable decision, its rationale, and rejected alternatives. | Future maintainers need to understand why an approach was chosen. |
DesignConstraint |
Records a boundary that must not be violated and why. | A design restriction preserves correctness, compatibility, security, or another essential property. |
Assumption |
Records an external fact or convention that the code relies on but does not verify. | Correctness depends on a protocol, deployment convention, or caller behavior outside the code's control. |
Use the enum overloads, such as SideEffectKind and MayBlockKind, when a standard category applies; provide the description that tells callers the actual condition or effect.
Precondition<TException> and BehaviorCase<TException> require TException to derive from Exception. The bundled code fix can generate XML <exception> documentation for typed preconditions.
Conditional behavior cases
BehaviorCase annotations are always usable in source, but are emitted into metadata only when ANNOTATIONS_BEHAVIOR_CASE is defined:
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANNOTATIONS_BEHAVIOR_CASE</DefineConstants>
</PropertyGroup>
Compatibility
Targets .NET 6.0 through .NET 10.0, .NET Framework 4.7.2 and 4.8, and .NET Standard 2.0 and 2.1.
Related documentation
License
Licensed under the GNU Lesser General Public License v3.0.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 is compatible. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net10.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TedToolkit.Annotations.Documentations:
| Package | Downloads |
|---|---|
|
TedToolkit.Annotations.Assertions
Source-generated precondition annotations backed by TedToolkit.Assertions. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.7.16.3 | 84 | 7/16/2026 |
| 2026.7.16.2 | 47 | 7/16/2026 |
| 2026.7.16.1 | 48 | 7/16/2026 |
| 2026.7.16 | 52 | 7/16/2026 |