{"record":{"id":"06b0a42ed804373d","repo":"stride3d/stride","slug":"shader-buffers-not-loaded-for-classsource-classname","errorCode":null,"errorMessage":"Shader buffers not loaded for {classSource.ClassName}","messagePattern":"Shader buffers not loaded for (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Shader.cs","lineNumber":766,"sourceCode":"\n    public static ShaderDefinition LoadAndCacheExternalShaderType(SymbolTable table, SpirvContext context, ShaderClassInstantiation classSource, SpirvContext declaringContext)\n    {\n        // Already processed?\n        if (table.DeclaredShaders.TryGetValue(classSource.ToClassNameWithGenerics(), out var cachedShader))\n            return cachedShader;\n\n        if (classSource.Buffer == null)\n        {\n            var shader = SpirvBuilder.GetOrLoadShader(table.ShaderLoader, classSource, table.CurrentMacros.AsSpan(), ResolveStep.Compile, declaringContext);\n            classSource.Buffer = shader;\n        }\n        var shaderType = LoadExternalShaderType(table, context, classSource);\n        return shaderType;\n    }\n\n    public static ShaderDefinition LoadExternalShaderType(SymbolTable table, SpirvContext context, ShaderClassInstantiation classSource)\n    {\n        var shaderBuffers = classSource.Buffer ?? throw new InvalidOperationException($\"Shader buffers not loaded for {classSource.ClassName}\");\n\n        var shaderType = CreateShaderType(table, context, shaderBuffers, classSource);\n\n        RegisterShaderType(table, shaderType);\n\n        return shaderType;\n    }\n\n\n    public override string ToString()\n    {\n        return\n$\"\"\"\nClass : {Name}\nGenerics : {string.Join(\", \", Generics)}\nInherits from : {string.Join(\", \", Mixins)}\nBody :\n{string.Join(\"\\n\", Elements)}","sourceCodeStart":748,"sourceCodeEnd":784,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Shader.cs#L748-L784","documentation":"Thrown by LoadExternalShaderType when the ShaderClassInstantiation has a null Buffer, meaning the shader's parse buffers were never loaded before attempting to create the shader type. The loader requires the source buffers to build the ShaderDefinition.","triggerScenarios":"Calling LoadExternalShaderType (or ShaderClass resolution that reaches it) on a classSource produced without the buffer-loading preprocessing step, e.g. after a failed or skipped parse of the external shader file.","commonSituations":"External shader file failed to load/parse earlier leaving Buffer null; manually constructed ShaderClassInstantiation used without running the buffer loading step; asset pipeline changes where shader files are not read before compilation.","solutions":["Ensure the shader's source buffers are loaded (classSource.Buffer populated) before resolving its type","Check for earlier load/parse errors of the external shader file and fix the root cause","Verify the shader file exists and is accessible so the loading step can populate the buffer"],"exampleFix":"// before\nvar type = ShaderClass.LoadExternalShaderType(table, context, classSource); // Buffer null\n// after\nclassSource.LoadBuffers(); // or use the loading API that populates Buffer\nvar type = ShaderClass.LoadExternalShaderType(table, context, classSource);","handlingStrategy":"validation","validationCode":"if (classSource.Buffer is null)\n    throw new InvalidOperationException($\"Load buffers for {classSource.ClassName} before resolving its type\");","typeGuard":"bool BuffersLoaded(ShaderClassInstantiation c) => c.Buffer is not null;","tryCatchPattern":"try { var t = ShaderDefinition.LoadExternalShaderType(table, context, classSource); }\ncatch (InvalidOperationException ex) { log.Error($\"Buffer not loaded: {ex.Message}\"); throw; }","preventionTips":["Always run the buffer-loading step before type resolution","Check earlier file load errors","Never construct ShaderClassInstantiation manually without loading buffers"],"tags":["sdsl","shader-loading","null-state"],"backgroundTag":"missing-dependency","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"}