{"record":{"id":"d736bf7b27dab744","repo":"stride3d/stride","slug":"argumentnullexception-parameters","errorCode":null,"errorMessage":"ArgumentNullException: parameters","messagePattern":"ArgumentNullException: parameters","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/Components/TemplateDescriptions/TemplateGeneratorHelper.cs","lineNumber":25,"sourceCode":"using Stride.Core.Assets.Templates;\nusing Stride.Core.Translation;\n\nnamespace Stride.Core.Assets.Editor.Components.TemplateDescriptions\n{\n    internal static class TemplateGeneratorHelper\n    {\n        /// <summary>\n        /// Invokes the given template generator safely. The generator will be prepared on the calling thread, and run from\n        /// a task. This methods will catch and log all exceptions occurring during the template generation.\n        /// </summary>\n        /// <param name=\"generator\">The template generator to run.</param>\n        /// <param name=\"parameters\">The parameters for the template generator.</param>\n        /// <param name=\"workProgress\">The view model used to report progress.</param>\n        /// <returns>A task that completes when the template generator has finished to run.</returns>\n        internal static async Task<bool> RunTemplateGeneratorSafe<TParameters>(ITemplateGenerator<TParameters> generator, TParameters parameters, WorkProgressViewModel workProgress) where TParameters : TemplateGeneratorParameters\n        {\n            if (generator == null) throw new ArgumentNullException(nameof(generator));\n            if (parameters == null) throw new ArgumentNullException(nameof(parameters));\n            var success = false;\n            try\n            {\n                success = await generator.PrepareForRun(parameters);\n                if (!success)\n                {\n                    // If the preparation failed without error, it means that the user cancelled the operation.\n                    if (!parameters.Logger.HasErrors)\n                        parameters.Logger.Info(Tr._p(\"Log\", \"Operation cancelled.\"));\n\n                    return false;\n                }\n            }\n            catch (Exception e)\n            {\n                parameters.Logger.Error(Tr._p(\"Log\", \"An exception occurred while generating the template.\"), e);\n            }\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/Components/TemplateDescriptions/TemplateGeneratorHelper.cs#L7-L43","documentation":"RunTemplateGeneratorSafe validates the parameters argument and throws ArgumentNullException when it is null. The generator cannot PrepareForRun without a TParameters instance derived from TemplateGeneratorParameters.","triggerScenarios":"Calling RunTemplateGeneratorSafe(generator, null, workProgress) — commonly when the TemplateGeneratorParameters object failed to build (e.g. empty/invalid project creation wizard input) and null was passed through.","commonSituations":"New-project wizard producing null parameters on invalid input; deserialization of template settings failing silently; caller skipping parameters construction on an error path.","solutions":["Construct and pass a valid TemplateGeneratorParameters-derived object","Fail earlier with a clear message if the wizard/validation produces null parameters","Null-check parameters at the calling layer before invoking the helper"],"exampleFix":"// before\nawait TemplateGeneratorHelper.RunTemplateGeneratorSafe(generator, parameters, progress);\n// after\nif (parameters == null) return false; // or surface validation error to the user\nawait TemplateGeneratorHelper.RunTemplateGeneratorSafe(generator, parameters, progress);","handlingStrategy":"validation","validationCode":"if (parameters == null) throw new ArgumentException(\"Template generator parameters were not built\", nameof(parameters));","typeGuard":"bool ValidParameters(TemplateGeneratorParameters p) => p != null && p.IsValid();","tryCatchPattern":"try { await RunTemplateGeneratorSafe(generator, parameters, progress); } catch (ArgumentNullException ex) when (ex.ParamName == \"parameters\") { /* surface parameter-build failure to the user */ }","preventionTips":["Build TemplateGeneratorParameters explicitly and validate wizard input before running","Fail the wizard step with a clear message instead of passing null downstream","Ensure deserialization of template settings never yields null silently"],"tags":["null-argument","template-generator","csharp"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}