{"record":{"id":"b865e5c0d62c2a7a","repo":"stride3d/stride","slug":"compilerparameters","errorCode":null,"errorMessage":"compilerParameters","messagePattern":"compilerParameters","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Effects/ShaderMixinContext.cs","lineNumber":41,"sourceCode":"\n        private string compositionString = null;\n\n        private readonly ShaderMixinSource currentMixinSourceTree;\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"ShaderMixinContext\" /> class.\n        /// </summary>\n        /// <param name=\"mixinTree\">The mixin tree.</param>\n        /// <param name=\"compilerParameters\">The default property container.</param>\n        /// <param name=\"registeredBuilders\">The registered builders.</param>\n        /// <exception cref=\"System.ArgumentNullException\">compilerParameters\n        /// or\n        /// registeredBuilders</exception>\n        public ShaderMixinContext(ShaderMixinSource mixinTree, ParameterCollection compilerParameters, Dictionary<string, IShaderMixinBuilder> registeredBuilders)\n        {\n            if (mixinTree == null) throw new ArgumentNullException(\"mixinTree\");\n            if (compilerParameters == null)\n                throw new ArgumentNullException(\"compilerParameters\");\n\n            if (registeredBuilders == null)\n                throw new ArgumentNullException(\"registeredBuilders\");\n\n            // TODO: use a copy of the compilerParameters?\n            this.currentMixinSourceTree = mixinTree;\n            this.compilerParameters = compilerParameters;\n            this.registeredBuilders = registeredBuilders;\n            this.parameterCollections = new Stack<ParameterCollection>();\n        }\n\n        /// <summary>\n        /// Gets or sets the child effect.\n        /// </summary>\n        /// <value>The child effect.</value>\n        public string ChildEffectName { get; set; }\n\n        /// <summary>","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Effects/ShaderMixinContext.cs#L23-L59","documentation":"The ShaderMixinContext constructor throws ArgumentNullException(\"compilerParameters\") when the ParameterCollection holding compilation parameters is null. The context relies on this collection for all permutation parameters, so it cannot operate without it. This is a fail-fast constructor guard.","triggerScenarios":"Calling new ShaderMixinContext(mixinTree, null, registeredBuilders), typically when a default/derived ParameterCollection was never created or a lookup for the compiler parameters returned null.","commonSituations":"Effect compiler setups that skip parameter collection creation; refactors where the parameters object became nullable; passing a method result that returns null when no parameters are set.","solutions":["Pass an empty ParameterCollection instead of null if no parameters exist","Create the ParameterCollection before constructing the context","Check the parameter-providing code path for null returns"],"exampleFix":"// before\nvar ctx = new ShaderMixinContext(tree, null, builders);\n// after\nvar ctx = new ShaderMixinContext(tree, new ParameterCollection(), builders);","handlingStrategy":"validation","validationCode":"if (compilerParameters is null) compilerParameters = new ParameterCollection(); // substitute empty collection","typeGuard":"static bool HasParameters(ParameterCollection p) => p != null;","tryCatchPattern":"try { var ctx = new ShaderMixinContext(tree, parameters, builders); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"compilerParameters\") { throw new InvalidOperationException(\"Compiler parameters must be initialized\", ex); }","preventionTips":["Create ParameterCollection early in the compile pipeline","Use an empty collection rather than null when no parameters are needed","Initialize defaults in the effect compiler setup"],"tags":["csharp","null-argument","constructor","shaders"],"backgroundTag":"null-argument","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"}