{"record":{"id":"5bf4d46b7d1a7c68","repo":"stride3d/stride","slug":"mixintree","errorCode":null,"errorMessage":"mixinTree","messagePattern":"mixinTree","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Effects/ShaderMixinContext.cs","lineNumber":39,"sourceCode":"        private readonly Stack<int> compositionIndices = new Stack<int>();\n        private readonly StringBuilder compositionStringBuilder = new StringBuilder();\n\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; }","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Effects/ShaderMixinContext.cs#L21-L57","documentation":"The ShaderMixinContext constructor throws ArgumentNullException(\"mixinTree\") when the shader mixin source tree passed to it is null. The mixin tree is the root ShaderMixinSource that the context will compose shaders into, so a null value makes the context unusable. This is a fail-fast guard in the constructor.","triggerScenarios":"Calling new ShaderMixinContext(null, compilerParameters, registeredBuilders) — e.g. when the shader source being compiled failed to produce a ShaderMixinSource earlier in the pipeline and the null result was passed straight through.","commonSituations":"Custom effect compiler pipelines that construct the context manually and pass a null mixin tree after a failed shader lookup or a null return from a factory method.","solutions":["Ensure the ShaderMixinSource passed to the constructor is created (new ShaderMixinSource(...)) before constructing ShaderMixinContext","Trace back where the null tree originates (often a failed shader name lookup) and fix the source of the null","Add a null check on the tree at the call site with a meaningful error message"],"exampleFix":"// before\nvar ctx = new ShaderMixinContext(GetTree(name), parameters, builders); // GetTree may return null\n// after\nvar tree = GetTree(name) ?? new ShaderMixinSource(name);\nvar ctx = new ShaderMixinContext(tree, parameters, builders);","handlingStrategy":"validation","validationCode":"if (mixinTree is null) throw new ArgumentNullException(nameof(mixinTree)); // validate before constructing\nvar ctx = new ShaderMixinContext(mixinTree, compilerParameters, registeredBuilders);","typeGuard":"static bool IsValidContextArgs(ShaderMixinSource t, ParameterCollection p, Dictionary<string, IShaderMixinBuilder> b) => t != null && p != null && b != null;","tryCatchPattern":"try { var ctx = new ShaderMixinContext(tree, parameters, builders); }\ncatch (ArgumentNullException ex) { logger.LogError(ex, \"ShaderMixinContext argument was null: {Param}\", ex.ParamName); throw; }","preventionTips":["Always construct ShaderMixinSource before building the context","Never pass method results that can return null directly into the constructor","Enable nullable reference types to catch null flow at compile time"],"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"}