dotnet/BenchmarkDotNet · error · ArgumentNullException
{name} can't be null
Error message
{name} can't be null What it means
Assertion.NotNull is an internal assertion helper annotated with [AssertionMethod]. It throws ArgumentNullException with message "{name} can't be null" when value is null. It is used internally to fail fast on null invariants the library depends on; the message text is a thin wrapper over ArgumentNullException.
Source
Thrown at src/BenchmarkDotNet/Helpers/Assertion.cs:11
using JetBrains.Annotations;
namespace BenchmarkDotNet.Helpers;
internal static class Assertion
{
[AssertionMethod]
public static void NotNull(string name, object? value)
{
if (value == null)
throw new ArgumentNullException(name, $"{name} can't be null");
}
}View on GitHub (pinned to b515068b61)
Solutions
- Inspect the stack trace to find which internal contract was violated and the originating config/setup.
- Ensure all required benchmark setup objects (attributes, configs, jobs) are fully specified.
- If state looks correct, report a BenchmarkDotNet issue with the reproduction; this asserts an internal invariant.
Defensive patterns
Strategy: try-catch
Try / catch
try { /* setup/run */ }
catch (ArgumentNullException ex) when (ex.Message.Contains("can't be null")) { /* inspect stack, report library issue */ } Prevention
- Fully specify all required benchmark setup (jobs, runtimes, descriptors).
- Inspect the stack trace to find the violated internal invariant.
- Report reproducible internal-assertion failures to BenchmarkDotNet.
When it happens
Trigger: An internal BenchmarkDotNet code path calls Assertion.NotNull(name, value) and value is null, indicating a violated precondition (e.g. a required descriptor, job, or report object was unexpectedly null).
Common situations: A previous step failed to produce a required object (a benchmark case missing a descriptor, a job without a runtime), corrupted/incomplete state, or a library bug where an internal contract was not upheld.
Related errors
- Value cannot be null. (Parameter 'values')
- 'source' cannot be null or whitespace.
- Missing extension on source '{source}', must have the extens
- Unsupported extension on source '{source}', must have the ex
- The value {value} is not assignable to {characteristic} prop
AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13).
Data as JSON: /api/errors/9c00c1a838b0329a.
Report an issue: GitHub.