stride3d/stride · error · ArgumentNullException
The BuildSteps property cannot be set to null
Error message
The BuildSteps property cannot be set to null
What it means
AssetCompilerResult.BuildSteps is documented to be null only when the logger recorded errors; otherwise the property must always hold a ListBuildStep. The setter enforces this invariant by throwing ArgumentNullException when a caller tries to assign null while no-error results still require a valid build step list.
Solutions
- Assign a new empty ListBuildStep instead of null when there are no steps.
- Only leave BuildSteps unset/null when Logger.HasErrors is true, per the documented contract.
- On compilation failure, log errors via the result's Logger and leave BuildSteps at its initialized value.
- Check result.Logger.HasErrors and result.BuildSteps for null before consuming steps downstream.
Example fix
// before
result.BuildSteps = null; // after clearing steps
// after
if (result.Logger.HasErrors)
{
// leave BuildSteps null per contract
}
else
{
result.BuildSteps = new ListBuildStep();
} Defensive patterns
Strategy: validation
Validate before calling
if (result.Logger.HasErrors)
{
// leave BuildSteps as-is (may be null per contract)
}
else
{
result.BuildSteps = buildSteps ?? new ListBuildStep();
} Type guard
static bool CanAssignBuildSteps(AssetCompilerResult result, ListBuildStep steps) => steps != null;
Try / catch
try
{
result.BuildSteps = steps;
}
catch (ArgumentNullException)
{
result.BuildSteps = new ListBuildStep(); // never assign null
} Prevention
- Never assign null to BuildSteps; use an empty ListBuildStep for no-op results.
- Remember the contract: BuildSteps is null only when Logger.HasErrors is true.
- Initialize ListBuildStep fields at declaration so they can never be null.
When it happens
Trigger: Assigning null to the BuildSteps property of AssetCompilerResult in code that post-processes compiler output, e.g. result.BuildSteps = null; instead of building an empty ListBuildStep or checking Logger.HasErrors first.
Common situations: Custom compiler wrappers clearing steps after failure handling; refactoring that replaced a local buildSteps list with null; test code constructing AssetCompilerResult and forgetting to set a (possibly empty) step list.
Related errors
- The relativePath argument is null or empty
- Value cannot be null. (Parameter 'location')
- Value cannot be null. (Parameter 'asset')
- Value cannot be null. (Parameter 'value')
- assetItem must be an absolute path
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/f58e99b5bf7f15cc.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/Compiler/AssetCompilerResult.cs:30
public class AssetCompilerResult : LoggerResult
{
private ListBuildStep buildSteps;
/// <summary>
/// Initializes a new instance of the <see cref="LoggerResult" /> class.
/// </summary>
/// <param name="moduleName">Name of the module.</param>
public AssetCompilerResult(string? moduleName = null)
: base(moduleName)
{
buildSteps = new ListBuildStep();
}
/// <summary>
/// Gets or sets the build steps generated for the build engine. This can be null if <see cref="Logger.HasErrors"/> is true.
/// </summary>
/// <value>The build step.</value>
public ListBuildStep BuildSteps { get { return buildSteps; } set { if (value == null) throw new ArgumentNullException("value", @"The BuildSteps property cannot be set to null"); buildSteps = value; } }
}
View on GitHub (pinned to 96fad776d2)