stride3d/stride · error · ArgumentException
Name cannot be empty
Error message
Name cannot be empty
What it means
ValidateNameNotEmpty is ProfilingKey's shared name guard: it returns the name unchanged when it is non-null and not whitespace, otherwise throws ArgumentException('Name cannot be empty', nameof(name)). All ProfilingKey constructors route through it to keep profiling key names meaningful.
Solutions
- Supply a non-empty descriptive name when constructing the ProfilingKey
- Validate/normalize the name (trim, fallback default) before construction
- Check why the source string is empty (missing config/constant) and fix the source
Example fix
// before var key = new ProfilingKey(categoryName); // may be "" // after var key = new ProfilingKey(string.IsNullOrWhiteSpace(categoryName) ? "default" : categoryName);
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(name)) name = "default"; var key = new ProfilingKey(name);
Type guard
bool isValidKeyName(string name) => !string.IsNullOrWhiteSpace(name);
Try / catch
try { key = new ProfilingKey(name); }
catch (ArgumentException) { key = new ProfilingKey("default"); } Prevention
- Validate profiling category names from config
- Trim and normalize names before constructing keys
- Fix empty sources (missing constants/config) rather than masking
When it happens
Trigger: new ProfilingKey(""), new ProfilingKey(parent, null), or any constructor receiving a whitespace-only name string.
Common situations: Names built by concatenation where parts are empty; configuration-driven profiling categories with missing values.
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
- Invalid 'text' argument
- 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/b9e6e110c8a49256.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core/Diagnostics/ProfilingKey.cs:82
/// </summary>
/// <value>The group.</value>
public ProfilingKey? Parent { get; }
/// <summary>
/// Gets the children.
/// </summary>
/// <value>
/// The children.
/// </value>
public List<ProfilingKey> Children { get; }
public override string ToString()
{
return Name;
}
private static string ValidateNameNotEmpty(string name) =>
!string.IsNullOrWhiteSpace(name) ? name : throw new ArgumentException("Name cannot be empty", nameof(name));
}
View on GitHub (pinned to 96fad776d2)