stride3d/stride · error · ArgumentException
can't be an empty string.
Error message
{paramName} can't be an empty string. What it means
ArgumentCheck.NotEmpty (string overload) throws ArgumentException when a string variable is the empty string (Length == 0). Null is rejected separately by NotNull first. This enforces that string parameters must contain at least one character.
Solutions
- Supply a non-empty string value before the call
- Trim/validate user or config input and reject empty strings early with a clearer message
- Check string.IsNullOrEmpty(variable) in the caller and handle it with a default or error
- If whitespace-only should also fail, use NotWhiteSpace instead and validate with string.IsNullOrWhiteSpace
Example fix
// before
var name = config["AssetName"]; // ""
ArgumentCheck.NotEmpty(name, nameof(name));
// after
var name = config["AssetName"];
if (string.IsNullOrWhiteSpace(name))
throw new InvalidDataException("AssetName must be a non-empty string"); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(value))
throw new ArgumentException("A non-empty string is required", nameof(value)); Type guard
bool IsPresent([NotNullWhen(true)] string? s) => !string.IsNullOrEmpty(s);
Try / catch
try { NotEmpty(name, nameof(name)); }
catch (ArgumentException ex) when (ex.ParamName == nameof(name))
{
// prompt user / substitute default
} Prevention
- Trim and validate text input at entry points
- Use [NotNullWhen(true)] guards for nullable strings
- Never accept string.Empty as a default for name-like fields
When it happens
Trigger: Calling ArgumentCheck.NotEmpty(variable, variableName) with string.Empty or "" (e.g. ""); a name/identifier field initialized to empty rather than a real value.
Common situations: Empty asset name or package name read from a form or config file; string.Split producing an empty first token; uninitialized string properties submitted by a UI.
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
- can't be null, empty, or consist only of whitespace…
- cannot be equal to .
- cannot be empty.
- ArgumentNullException: paramName
- Custom strides is not supported with packed PixelFormats
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b0200b642b60507b.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs:137
/// <remarks>
/// Before checking the <paramref name="variable"/>, a call is made to
/// <see cref="NotNull"/>.
/// </remarks>
/// <exception cref="ArgumentNullException">
/// The <paramref name="variable"/> cannot be <see langword="null"/>.
/// </exception>
/// <exception cref="ArgumentException">
/// The <paramref name="variable"/> cannot be an empty <see cref="string"/>.
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void NotEmpty(string variable, string variableName)
{
var paramName = variableName ?? "The variable";
// Variable cannot be null
NotNull(variable, paramName);
if (variable.Length == 0)
{
throw new ArgumentException($"{paramName} can't be an empty string.");
}
}
/// <summary>
/// Checks whether the <paramref name="variable"/> is different from <paramref name="value"/>.
/// Otherwise throws an exception.
/// </summary>
/// <typeparam name="T">The type of the <paramref name="variable"/>.</typeparam>
/// <param name="variable">The value to check.</param>
/// <param name="value">The value to compare to for inequality.</param>
/// <param name="variableName">The name of the variable being checked.</param>
/// <exception cref="ArgumentException">
/// <paramref name="variable"/> is equal to the <paramref name="value"/>.
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void NotEquals<T>(T variable, T value, string variableName)
{
var paramName = variableName ?? "The variable";View on GitHub (pinned to 96fad776d2)