{"record":{"id":"b5322f1b49ab8bde","repo":"dotnet/efcore","slug":"unsupported-type-type","errorCode":null,"errorMessage":"Unsupported type: {type}","messagePattern":"Unsupported type: (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Query/Internal/PrecompiledQueryCodeGenerator.cs","lineNumber":1263,"sourceCode":"\n                expression = methodCallExpression.Object;\n                continue;\n            }\n\n            throw new InvalidOperationException(RelationalStrings.InvalidArgumentToExecuteUpdate);\n        }\n\n        // The expression tree is nested inside-out (last SetProperty call is the outermost node),\n        // so setters were added in reverse order. Reverse to restore source code order.\n        var settersArray = settersBuilder.BuildSettersExpression();\n        return Expression.NewArrayInit(settersArray.Type.GetElementType()!, settersArray.Expressions.Reverse());\n    }\n\n    private static ITypeSymbol GetTypeSymbol(Compilation compilation, Type type)\n    {\n        if (type.IsByRef || type.IsPointer || type.IsGenericParameter || type.IsByRefLike)\n        {\n            throw new NotSupportedException($\"Unsupported type: {type}\");\n        }\n\n        if (type.IsArray)\n        {\n            var elementSymbol = GetTypeSymbol(compilation, type.GetElementType()!);\n            return compilation.CreateArrayTypeSymbol(elementSymbol, type.GetArrayRank());\n        }\n\n        if (type.IsGenericType && !type.IsGenericTypeDefinition)\n        {\n            var genericDefinition = (INamedTypeSymbol)GetTypeSymbol(\n                compilation,\n                type.GetGenericTypeDefinition());\n\n            var typeArguments = type\n                .GetGenericArguments()\n                .Select(t => GetTypeSymbol(compilation, t))\n                .ToArray();","sourceCodeStart":1245,"sourceCodeEnd":1281,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Query/Internal/PrecompiledQueryCodeGenerator.cs#L1245-L1281","documentation":"Thrown in PrecompiledQueryCodeGenerator.GetTypeSymbol (line 1263) when asked to map a runtime System.Type to a Roslyn ITypeSymbol but the type is by-ref, a pointer, a generic parameter, or a ref-like struct. These categories cannot be embedded in generated interceptor source, so GetTypeSymbol rejects them up front with NotSupportedException before attempting metadata lookup.","triggerScenarios":"Precompiled-query code generation encounters a type used in an intercepted operator that is a ref/out parameter type, an unsafe pointer type, a generic type parameter (T), or a ref struct (Span<T>, ReadOnlySpan<T>, etc.). GetTypeSymbol checks type.IsByRef || type.IsPointer || type.IsGenericParameter || type.IsByRefLike and throws.","commonSituations":"A query operator signature involves a ref struct such as Span<T> or a by-ref parameter. Capturing a generic type parameter that has no concrete symbol. Using unsafe/interop types in a query slated for precompilation. These types cannot appear in the generated interceptor's parameter list.","solutions":["Avoid queries/operators whose signatures use ref, pointer, generic-parameter, or ref-struct types when precompiling.","Refactor to use a concrete, embeddable type (e.g. an array or IReadOnlyList<T> instead of Span<T>) for the relevant operation.","Exclude the query using such a type from precompilation.","If the type comes from a captured variable, materialize it to a normal reference type before the precompiled query."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Reject unsupported type categories before code generation\nstatic bool IsEmbeddableType(Type t)\n    => !t.IsByRef && !t.IsPointer && !t.IsGenericParameter && !t.IsByRefLike;","typeGuard":"static bool IsEmbeddableType(Type t)\n    => !t.IsByRef && !t.IsPointer && !t.IsGenericParameter && !t.IsByRefLike;","tryCatchPattern":"try { /* generate */ }\ncatch (NotSupportedException ex) when (ex.Message.StartsWith(\"Unsupported type\"))\n{ /* switch to an embeddable type or exclude the query */ }","preventionTips":["Avoid ref/pointer/ref-struct/generic-parameter types in precompiled query operators.","Use arrays or interfaces instead of Span<T> in query signatures."],"tags":["ef-core","precompiled-query","type-system","code-generation","design-time"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}