{"record":{"id":"b115055c2e4df156","repo":"stride3d/stride","slug":"registeredbuilders","errorCode":null,"errorMessage":"registeredBuilders","messagePattern":"registeredBuilders","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Effects/ShaderMixinContext.cs","lineNumber":44,"sourceCode":"        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>\n        /// Pushes the current parameters collection being used.\n        /// </summary>\n        /// <typeparam name=\"T\">Type of the parameter collection</typeparam>","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Effects/ShaderMixinContext.cs#L26-L62","documentation":"The ShaderMixinContext constructor throws ArgumentNullException(\"registeredBuilders\") when the dictionary mapping shader names to IShaderMixinBuilder instances is null. Without this registry the context cannot resolve mixin builders by name. This is a fail-fast constructor guard.","triggerScenarios":"Calling new ShaderMixinContext(mixinTree, compilerParameters, null) — e.g. when building a fresh registry asynchronously and passing it before initialization, or when aDI/lookup returned null.","commonSituations":"Custom compiler hosts that forget to register builder dictionaries; passing a variable that is populated only later (race with initialization).","solutions":["Pass a non-null dictionary (use ShaderMixinManager.RegisteredBuilders or an empty Dictionary<string, IShaderMixinBuilder>)","Ensure the registry is initialized before context construction","Use ShaderMixinManager.Register to populate builders rather than a hand-rolled null dictionary"],"exampleFix":"// before\nvar ctx = new ShaderMixinContext(tree, parameters, lazyRegistry?.Value); // may be null\n// after\nvar builders = lazyRegistry?.Value ?? new Dictionary<string, IShaderMixinBuilder>();\nvar ctx = new ShaderMixinContext(tree, parameters, builders);","handlingStrategy":"validation","validationCode":"if (registeredBuilders is null) registeredBuilders = new Dictionary<string, IShaderMixinBuilder>();","typeGuard":"static bool HasBuilderRegistry(Dictionary<string, IShaderMixinBuilder> b) => b != null;","tryCatchPattern":"try { var ctx = new ShaderMixinContext(tree, parameters, builders); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"registeredBuilders\") { throw new InvalidOperationException(\"Builder registry must be initialized\", ex); }","preventionTips":["Prefer ShaderMixinManager.RegisteredBuilders as the shared registry","Initialize the registry dictionary at application startup","Avoid lazily-populated registries passed before initialization"],"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"}