stride3d/stride · error · ArgumentException
Invalid 'text' argument
Error message
Invalid 'text' argument
What it means
PerformanceCheckBlock's constructor measures a named block against a PerformanceReport. It validates that the block name (text) is not null/whitespace before calling report.BeginMeasure(text), throwing ArgumentException('Invalid 'text' argument') for empty names.
Solutions
- Pass a non-empty descriptive name, e.g. new PerformanceCheckBlock("RenderLoop", report)
- Guard with string.IsNullOrWhiteSpace before constructing and skip/throw a clearer error
- Ensure report itself is not null as well (it throws ArgumentNullException next)
Example fix
// before
using (new PerformanceCheckBlock(label, report)) { ... }
// after
if (!string.IsNullOrWhiteSpace(label))
using (new PerformanceCheckBlock(label, report)) { ... } Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(text) || report == null) return null; // skip block
using (new PerformanceCheckBlock(text, report)) { /* ... */ } Type guard
bool validBlockArgs(string text, PerformanceReport r) => !string.IsNullOrWhiteSpace(text) && r != null;
Try / catch
try { return new PerformanceCheckBlock(text, report); }
catch (ArgumentException) { return null; } Prevention
- Use fixed string literals for block names
- Validate dynamic labels before instrumentation
- Check report for null at the call site
When it happens
Trigger: new PerformanceCheckBlock(null, report), "", " ", or a name computed from string.Format/interpolation of empty variables; also passing text from config/CLI that resolves to empty.
Common situations: Instrumenting code where the label is generated dynamically (e.g. nameof falls back to empty after a refactor) or read from an unvalidated settings value.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Name cannot be empty
- Value must be > 0
- The provided path is not a valid path name.
- Build manifest [ ] doesn't exist
- This tool requires an input file (package, project, or…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/faae9d379027aa04.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core/Diagnostics/PerformanceReport.cs:82
var totalTicks = measures.Sum(info => info.Ticks);
foreach (var info in measures)
{
sb.AppendLine($"{info.Text}: {info.Milliseconds} ms, {info.Ticks} ticks ({info.Ticks * 100.0 / totalTicks:F2}%)");
}
return sb.ToString();
}
}
public class PerformanceCheckBlock : IDisposable
{
private readonly PerformanceReport report;
public PerformanceCheckBlock(string text, PerformanceReport report)
{
if (string.IsNullOrWhiteSpace(text))
throw new ArgumentException("Invalid 'text' argument");
ArgumentNullException.ThrowIfNull(report);
this.report = report;
this.report.BeginMeasure(text);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
report.EndMeasure();
}View on GitHub (pinned to 96fad776d2)