{"record":{"id":"e2499c70bfe5b11a","repo":"stride3d/stride","slug":"bytecode","errorCode":null,"errorMessage":"bytecode","messagePattern":"bytecode","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Effects/Effect.cs","lineNumber":50,"sourceCode":"        /// Initializes a new instance of the <see cref=\"Effect\"/> class.\n        /// </summary>\n        /// <param name=\"device\">The device.</param>\n        /// <param name=\"bytecode\">The bytecode.</param>\n        /// <param name=\"usedParameters\">The parameters used to create this shader (from a sdfx).</param>\n        /// <exception cref=\"System.ArgumentNullException\">\n        /// device\n        /// or\n        /// bytecode\n        /// </exception>\n        public Effect(GraphicsDevice device, EffectBytecode bytecode)\n        {\n            InitializeFrom(device, bytecode);\n        }\n\n        internal void InitializeFrom(GraphicsDevice device, EffectBytecode bytecode)\n        {\n            if (device == null) throw new ArgumentNullException(\"device\");\n            if (bytecode == null) throw new ArgumentNullException(\"bytecode\");\n\n            this.graphicsDeviceDefault = device;\n            this.bytecode = bytecode;\n            Initialize();\n        }\n\n        /// <summary>\n        /// Gets the bytecode.\n        /// </summary>\n        /// <value>The bytecode.</value>\n        public EffectBytecode Bytecode\n        {\n            get\n            {\n                return bytecode;\n            }\n        }\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Effects/Effect.cs#L32-L68","documentation":"Argument-null validation in Effect.InitializeFrom, reached through the Effect(GraphicsDevice, EffectBytecode) constructor: the bytecode parameter is null. An Effect wraps compiled shader bytecode; without bytecode there is nothing to initialize the effect from, so the guard rejects the call (the docs also list a null device as an accepted failure of this initialization path).","triggerScenarios":"Calling new Effect(device, null) or InitializeFrom(device, bytecode) where bytecode comes from EffectBytecode.Load/serialization and returned null — e.g. failed resource lookup, missing compiled effect asset, or deserialization of an empty stream.","commonSituations":"Renamed/moved effect shader source so the compiled bytecode asset is missing; effects database not built; loading effects from a bad/empty stream; asset import pipeline failures.","solutions":["Verify the bytecode source (effect asset/stream) loads successfully before constructing the Effect.","Rebuild the Stride effects database / shader compilation output so the bytecode asset exists.","Check that deserialization of EffectBytecode returned non-null before calling InitializeFrom."],"exampleFix":"// before\nvar effect = new Effect(device, EffectBytecode.Load(stream)); // may be null\n// after\nvar bytecode = EffectBytecode.Load(stream) ?? throw new InvalidOperationException(\"Effect bytecode missing\");\nvar effect = new Effect(device, bytecode);","handlingStrategy":"validation","validationCode":"EffectBytecode bytecode = EffectBytecode.Load(stream);\nif (bytecode == null)\n    throw new InvalidOperationException(\"Effect bytecode failed to load — check the effect asset exists\");\nvar effect = new Effect(device, bytecode);","typeGuard":"bool IsValidBytecode(EffectBytecode b) => b is { Data: { Length: > 0 } };","tryCatchPattern":"try { effect = new Effect(device, bytecode); }\ncatch (ArgumentNullException ex) { log.Error(ex, \"Null bytecode — effect asset missing or empty\"); throw; }","preventionTips":["Rebuild the effects database after renaming or moving shader sources.","Validate that bytecode streams are non-empty before constructing effects.","Fail fast in the asset-loading layer with a clear message instead of passing null."],"tags":["argument-null","effect","bytecode","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-23T08:17:48.524Z"}