stride3d/stride · error · ArgumentException

Invalid template description for this generator.

Error message

Invalid template description for this generator.

What it means

SpriteSheetFromFileTemplateGenerator.CreateAssets selects which factory creates the sprite sheet by matching the template description's Id against known SpriteSheet ids. Any other id means the generator was given a description it cannot handle, so it throws ArgumentException.

Solutions

  1. Register the template with the correct Id (SpriteSheetId or UISpriteSheetId) for this generator
  2. Use the appropriate template generator class for your description's id
  3. Update custom template ids to match the current Stride version's identifiers

Example fix

// before
new TemplateDescription(id: "MySpriteSheet", generator: typeof(SpriteSheetFromFileTemplateGenerator)); // id not recognized
// after
new TemplateDescription(id: SpriteSheetFromFileTemplateGenerator.SpriteSheetId.ToString(), generator: typeof(SpriteSheetFromFileTemplateGenerator));
Defensive patterns

Strategy: validation

Validate before calling

bool supported = desc.Id == SpriteSheetFromFileTemplateGenerator.SpriteSheetId
             || desc.Id == SpriteSheetFromFileTemplateGenerator.UISpriteSheetId;
if (!supported) throw new ArgumentException(desc.Id.ToString());

Type guard

bool IsSpriteSheetTemplate(TemplateDescription d) => d.Id == SpriteSheetFromFileTemplateGenerator.SpriteSheetId || d.Id == SpriteSheetFromFileTemplateGenerator.UISpriteSheetId;

Try / catch

try { foreach (var a in gen.CreateAssets(parameters)) yield return a; }
catch (ArgumentException) { // fall back to the generic sprite template generator
}

Prevention

When it happens

Trigger: Invoking this generator with a TemplateDescription whose Id is neither SpriteSheetId nor UISpriteSheetId — e.g. the template registration wires a generic sprite description to the sprite-sheet-from-file generator.

Common situations: Custom sprite/sprite-sheet templates mistakenly reusing this generator class; Stride version upgrades changing template ids so older descriptions no longer match.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/093e1ef9a67b5898. Report an issue: GitHub.

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/Templates/SpriteSheetFromFileTemplateGenerator.cs:48

        public override bool IsSupportingTemplate(TemplateDescription templateDescription)
        {
            return templateDescription.Id == SpriteSheetId || templateDescription.Id == UISpriteSheetId;
        }

        protected override IEnumerable<AssetItem> CreateAssets(AssetTemplateGeneratorParameters parameters)
        {
            var sources = parameters.Tags.Get(SourceFilesPathKey);
            if (sources == null)
                return base.CreateAssets(parameters);

            SpriteSheetAsset asset;

            if (parameters.Description.Id == SpriteSheetId)
                asset = SpriteSheetSprite2DFactory.Create();
            else if (parameters.Description.Id == UISpriteSheetId)
                asset = SpriteSheetUIFactory.Create();
            else
                throw new ArgumentException("Invalid template description for this generator.");

            using (var textureTool = new TextureTool())
            {
                foreach (var source in sources)
                {
                    int width = 0;
                    int height = 0;
                    parameters.Logger.Verbose($"Processing image \"{source}\"");
                    try
                    {
                        var image = textureTool.Load(source.ToString(), false);
                        width = image.Width;
                        height = image.Height;
                    }
                    catch (Exception)
                    {
                        parameters.Logger.Warning($"Unable to retrieve the size of \"{source}\"");
                    }

View on GitHub (pinned to 96fad776d2)