{"record":{"id":"e0a3ea04e0fbc9ae","repo":"stride3d/stride","slug":"can-t-import-symbol-for-nameof-functiongrouptype","errorCode":null,"errorMessage":"Can't import symbol for {nameof(FunctionGroupType)}","messagePattern":"Can't import symbol for (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Core/SymbolTypes.cs","lineNumber":559,"sourceCode":"        bool isCurrentShader = symbol.OwnerType == table.CurrentShader;\n\n        // Check if symbol is already imported\n        if (symbol.IdRef != 0)\n        {\n            if (!isCurrentShader)\n                symbol = symbol with { MemberAccessWithImplicitThis = symbol.Type };\n            return symbol;\n        }\n\n        // Find same symbol in owner type\n        if (symbol.OwnerType == null)\n            throw new InvalidOperationException();\n\n        if (isCurrentShader && symbol.IdRef == 0)\n            throw new InvalidOperationException(\"Symbols in current shader should be resolved\");\n\n        if (symbol.Type is FunctionGroupType)\n            throw new InvalidOperationException($\"Can't import symbol for {nameof(FunctionGroupType)}\");\n\n        if (symbol.Type is FunctionType)\n        {\n            var methods = CollectionsMarshal.AsSpan(symbol.OwnerType.Methods);\n            foreach (ref var c in methods)\n            {\n                if (c.Symbol.Id == symbol.Id && c.Symbol.Type == symbol.Type)\n                {\n                    if (c.Symbol.IdRef == 0)\n                    {\n                        // Emit symbol\n                        // TODO: emit it only when this specific method is *selected* as proper overload (signature) & override (base vs this)\n                        var shaderId = context.GetOrImportShader(symbol.OwnerType);\n                        context.ImportShaderMethod(shaderId, ref c.Symbol, c.Flags);\n                    }\n\n                    symbol.IdRef = c.Symbol.IdRef;\n                    if (!isCurrentShader)","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Core/SymbolTypes.cs#L541-L577","documentation":"During symbol import (resolving a symbol referenced from another shader), symbols typed FunctionGroupType cannot be imported across shader boundaries, so the import routine throws InvalidOperationException. Function groups are shader-local compilation constructs, not shareable symbol values.","triggerScenarios":"Importing a symbol whose Type is FunctionGroupType via the symbol-import path (symbol.IdRef from a foreign shader, isCurrentShader == false); e.g. shader code referencing a function group declared in an imported/included shader.","commonSituations":"A shader tries to use (call or take a reference to) a function group from another shader/module; shader mixins or inheritance pulling in symbols that include function-group entries; refactoring code to move a function group across shader files.","solutions":["Don't reference the function-group symbol from the importing shader; re-declare or re-implement the needed function group locally.","Filter function-group-typed symbols out of the import set before calling the import routine.","Import the concrete FunctionType members or the underlying functions instead of the group itself.","Catch InvalidOperationException around symbol import and surface which symbol failed so the shader author can fix the reference."],"exampleFix":"// before\nImportSymbol(symbol); // throws for FunctionGroupType\n// after\nif (symbol.Type is FunctionGroupType)\n    continue; // skip or handle locally; function groups cannot be imported\nImportSymbol(symbol);","handlingStrategy":"type-guard","validationCode":"if (symbol.Type is FunctionGroupType)\n{\n    // skip, handle locally, or report: cannot import function groups across shaders\n    return;\n}\nImportSymbol(symbol);","typeGuard":"static bool IsImportable(Symbol symbol) =>\n    symbol.Type is not FunctionGroupType &&\n    !(symbol.OwnerType == null && symbol.IdRef == 0);","tryCatchPattern":"try { ImportSymbol(symbol); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(nameof(FunctionGroupType)))\n{\n    // log the symbol and re-declare the function group locally instead\n}","preventionTips":["Filter out FunctionGroupType symbols before any cross-shader import pass.","Keep function groups local to the shader that declares them; share concrete functions instead.","Run a symbol audit over imported shader sets to catch function-group references early in the pipeline."],"tags":["csharp","shaders","symbols","import"],"backgroundTag":"unsupported-operation","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"}