stride3d/stride · error · InvalidOperationException
[ ] cannot be null in
Error message
[{nameof(Description)}] cannot be null in {GetType().Name} What it means
TemplateGeneratorParameters.ValidateParameters throws this InvalidOperationException when the Description property — the TemplateDescription describing which template to run — is null. Without a description the generator cannot know what files to produce or what scope applies, so validation rejects the parameters before any generation starts.
Solutions
- Assign a valid TemplateDescription to the Description property before calling Validate().
- Load the description through the TemplateManager/template provider for the template Id you intend to run and check it is non-null.
- If constructing descriptions by hand, ensure you pass it into the parameters object rather than only keeping it locally.
Example fix
// before
var p = new SessionTemplateGeneratorParameters { Name = "MyGame", OutputDirectory = dir, Logger = logger, Session = session };
p.Validate(); // throws: Description null
// after
var desc = TemplateManager.FindTemplate(templateId); // non-null TemplateDescription
var p = new SessionTemplateGeneratorParameters { Name = "MyGame", OutputDirectory = dir, Description = desc, Logger = logger, Session = session };
p.Validate(); Defensive patterns
Strategy: validation
Validate before calling
if (p.Description == null)
throw new ArgumentException("TemplateGeneratorParameters.Description must be set to the resolved TemplateDescription before Validate()."); Type guard
bool HasDescription(TemplateGeneratorParameters p) => p.Description is not null;
Try / catch
try { p.Validate(); }
catch (InvalidOperationException ex) when (ex.Message.Contains(nameof(TemplateGeneratorParameters.Description)))
{
// re-resolve the template by Id and retry
} Prevention
- Resolve the TemplateDescription via TemplateManager and null-check it before constructing parameters.
- Include Description in every parameters object initializer, not just in copies.
- When a template lookup fails, fail loudly instead of passing null through.
When it happens
Trigger: Calling Validate() on any TemplateGeneratorParameters-derived object where Description was never assigned. Note the preceding OutputDirectory check dereferences Description, so a null Description with a null OutputDirectory throws the OutputDirectory error first; setting OutputDirectory (or a session-scope description) exposes this null-Description error.
Common situations: Manually constructed parameters in unit tests or tooling that only set Name/Logger; loading templates via a template provider that failed silently and returned no TemplateDescription; forgetting to assign Description while copying all other fields to a new parameters object.
Related errors
- [ ] cannot be null in
- [ ] cannot be null in
- [ ] cannot be null in
- [ ] cannot be null in
- [ ] cannot be null in
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/cee939ffd874b1f5.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/Templates/TemplateGeneratorParameters.cs:227
public void SetTag<T>(PropertyKey<T> key, T value)
{
Tags[key] = value;
}
protected virtual void ValidateParameters()
{
if (Name == null)
{
throw new InvalidOperationException($"[{nameof(Name)}] cannot be null in {GetType().Name}");
}
if (OutputDirectory == null && Description.Scope == TemplateScope.Session)
{
throw new InvalidOperationException($"[{nameof(OutputDirectory)}] cannot be null in {GetType().Name}");
}
if (Description == null)
{
throw new InvalidOperationException($"[{nameof(Description)}] cannot be null in {GetType().Name}");
}
if (Logger == null)
{
throw new InvalidOperationException($"[{nameof(Logger)}] cannot be null in {GetType().Name}");
}
}
}
View on GitHub (pinned to 96fad776d2)