{"record":{"id":"93a0eb9978b27878","repo":"stride3d/stride","slug":"nameof-description-nameof-description-scope-must-be-93a0eb","errorCode":null,"errorMessage":"[{nameof(Description)}.{nameof(Description.Scope)}] must be {TemplateScope.Asset} in {GetType().Name}","messagePattern":"\\[(.+?)\\.(.+?)\\] must be (.+?) in (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Templates/TemplateGeneratorParameters.cs","lineNumber":90,"sourceCode":"    }\n\n    public UDirectory TargetLocation { get; }\n\n    public List<UFile> SourceFiles { get; }\n\n    /// <summary>\n    /// Indicates whether the session has to be saved after the asset template generator has completed. The default is <c>false</c>.\n    /// </summary>\n    /// <remarks>This is an out parameter that asset template generator should set if needed.</remarks>\n    public bool RequestSessionSave { get; set; } = false;\n\n    protected override void ValidateParameters()\n    {\n        base.ValidateParameters();\n\n        if (Description.Scope != TemplateScope.Asset)\n        {\n            throw new InvalidOperationException($\"[{nameof(Description)}.{nameof(Description.Scope)}] must be {TemplateScope.Asset} in {GetType().Name}\");\n        }\n        if (Package == null)\n        {\n            throw new InvalidOperationException($\"[{nameof(Package)}] cannot be null in {GetType().Name}\");\n        }\n    }\n}\n\n/// <summary>\n/// Parameters used by <see cref=\"ITemplateGenerator{TParameters}\"/>\n/// </summary>\npublic abstract class TemplateGeneratorParameters\n{\n    protected TemplateGeneratorParameters()\n    {\n    }\n\n    protected TemplateGeneratorParameters(TemplateGeneratorParameters parameters)","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Templates/TemplateGeneratorParameters.cs#L72-L108","documentation":"AssetTemplateGeneratorParameters.ValidateParameters throws this InvalidOperationException when the template Description.Scope is not TemplateScope.Asset. Asset templates must declare Asset scope so the generator knows it creates assets inside a package; a description with Package or Session scope is a configuration mismatch and validation aborts before generation runs.","triggerScenarios":"Calling Validate() on an AssetTemplateGeneratorParameters instance whose Description comes from a template description with Scope set to Package or Session — e.g. reusing a package template's TemplateDescription with asset parameters.","commonSituations":"Wiring a custom asset generator to the wrong .sdtpl description file; editing a template description's Scope field by hand and leaving it as Package; programmatically building a TemplateDescription and forgetting to set Scope = TemplateScope.Asset.","solutions":["Set the Description's Scope to TemplateScope.Asset (or fix the template description file).","Use the TemplateDescription that actually corresponds to the asset template being run.","If the template is package-scoped, switch to PackageTemplateGeneratorParameters instead."],"exampleFix":"// before\nvar desc = new TemplateDescription { Id = ..., Scope = TemplateScope.Package };\nvar p = new AssetTemplateGeneratorParameters(targetLocation) { Description = desc, ... };\np.Validate(); // throws\n\n// after\nvar desc = new TemplateDescription { Id = ..., Scope = TemplateScope.Asset };\nvar p = new AssetTemplateGeneratorParameters(targetLocation) { Description = desc, ... };\np.Validate();","handlingStrategy":"validation","validationCode":"if (p is AssetTemplateGeneratorParameters ap && ap.Description?.Scope != TemplateScope.Asset)\n    throw new InvalidOperationException($\"Asset template requires Scope == TemplateScope.Asset, got {ap.Description?.Scope}.\");","typeGuard":"bool IsAssetScoped(AssetTemplateGeneratorParameters p) => p.Description?.Scope == TemplateScope.Asset;","tryCatchPattern":"try { p.Validate(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(nameof(TemplateDescription.Scope)))\n{\n    // correct the description's Scope or switch parameters type\n}","preventionTips":["Set Scope = TemplateScope.Asset in every TemplateDescription used with asset generators.","Load descriptions via TemplateManager by template Id instead of hand-building them ad hoc.","Review hand-edited .sdtpl files after upgrades — Scope is a common field to get wrong."],"tags":["csharp","invalid-enum-value","templates","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}