TedToolkit.Assertions.Logging
2026.5.15
dotnet add package TedToolkit.Assertions.Logging --version 2026.5.15
NuGet\Install-Package TedToolkit.Assertions.Logging -Version 2026.5.15
<PackageReference Include="TedToolkit.Assertions.Logging" Version="2026.5.15" />
<PackageVersion Include="TedToolkit.Assertions.Logging" Version="2026.5.15" />
<PackageReference Include="TedToolkit.Assertions.Logging" />
paket add TedToolkit.Assertions.Logging --version 2026.5.15
#r "nuget: TedToolkit.Assertions.Logging, 2026.5.15"
#:package TedToolkit.Assertions.Logging@2026.5.15
#addin nuget:?package=TedToolkit.Assertions.Logging&version=2026.5.15
#tool nuget:?package=TedToolkit.Assertions.Logging&version=2026.5.15
TedToolkit.Assertions.Logging
An extension for TedToolkit.Assertions that routes assertion failures through Microsoft.Extensions.Logging instead of (or in addition to) throwing exceptions.
Installation
dotnet add package TedToolkit.Assertions.Logging
This package requires TedToolkit.Assertions (installed automatically as a dependency).
Supported Frameworks
.NET 6 / 7 / 8 / 9 / 10, .NET Framework 4.7.2 / 4.8, .NET Standard 2.0 / 2.1
Usage
Push a LoggerScope around the code whose assertion failures you want logged. The most ergonomic entry points are the Push / FastPush extension methods on ILogger:
using TedToolkit.Assertions;
using TedToolkit.Assertions.Logging;
// async-safe (flows across await boundaries)
using (logger.Push())
{
name.Must().Not.BeNullOrEmpty();
age.Should().BeGreaterThan(0);
await DoWorkAsync();
}
// synchronous fast path (thread-local, ref struct — cannot cross await)
using (logger.FastPush())
{
name.Must().Not.BeNullOrEmpty();
}
Severity → log level
| Assertion | Log level | Throws? |
|---|---|---|
Could |
Information |
no |
Should |
Warning |
no |
Must |
Error |
ArgumentException |
Aggregating with AssertionScope
Failures inside an AssertionScope are collected and reported once on scope exit. The log level reflects the highest severity in the batch:
using (logger.Push())
using (new AssertionScope("validating order").Push())
{
order.Name.Must().Not.BeNullOrEmpty();
order.Amount.Must().BeGreaterThan(0);
order.Discount.Should().BeInRange(0, 100);
}
// One log entry with all failures; throws ArgumentException because the batch
// contains MUST failures.
Behavior notes
- The first reference to
LoggerScopepermanently replacesAssertionStrategy.ItemStrategyandAssertionStrategy.ScopeStrategyfor the AppDomain. Don't combine this package with another strategy customization. - Outside a
LoggerScope,Could/Shouldfailures are silently dropped (no log, no throw).Muststill throws anArgumentException. Push aLoggerScopebefore running assertions whose failures you want surfaced.
License
| 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
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- TedToolkit.Assertions (>= 2026.5.15)
-
.NETFramework 4.8
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- TedToolkit.Assertions (>= 2026.5.15)
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- TedToolkit.Assertions (>= 2026.5.15)
-
.NETStandard 2.1
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- TedToolkit.Assertions (>= 2026.5.15)
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- TedToolkit.Assertions (>= 2026.5.15)
-
net6.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- TedToolkit.Assertions (>= 2026.5.15)
-
net7.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- TedToolkit.Assertions (>= 2026.5.15)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- TedToolkit.Assertions (>= 2026.5.15)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- TedToolkit.Assertions (>= 2026.5.15)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.5.15 | 96 | 5/15/2026 |
| 2025.12.23.1 | 205 | 12/23/2025 |
| 2025.12.23 | 202 | 12/23/2025 |
| 2025.12.17 | 287 | 12/17/2025 |
| 2025.12.12.2 | 148 | 12/12/2025 |
| 2025.12.12.1 | 145 | 12/12/2025 |
| 2025.12.12 | 159 | 12/12/2025 |
| 2025.12.9 | 465 | 12/9/2025 |
| 2025.11.25 | 218 | 11/25/2025 |
| 2025.11.24.3 | 218 | 11/24/2025 |
| 2025.11.24.2 | 209 | 11/24/2025 |
| 2025.11.24.1 | 217 | 11/24/2025 |
| 2025.11.24 | 212 | 11/24/2025 |
| 2025.11.21 | 431 | 11/21/2025 |
| 2025.11.20.4 | 430 | 11/20/2025 |
| 2025.11.20.3 | 428 | 11/20/2025 |
| 2025.11.20.2 | 451 | 11/20/2025 |
| 2025.11.20.1 | 430 | 11/20/2025 |
| 2025.11.20 | 437 | 11/20/2025 |
| 2025.11.19.6 | 425 | 11/19/2025 |