{"record":{"id":"0b00830812a88d59","repo":"clockworklabs/SpacetimeDB","slug":"unsupported-special-type-type-type-specialtype","errorCode":null,"errorMessage":"Unsupported special type {type} ({type.SpecialType})","messagePattern":"Unsupported special type (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"crates/bindings-csharp/BSATN.Codegen/Utils.cs","lineNumber":138,"sourceCode":"        return type switch\n        {\n            ITypeParameterSymbol typeParameter => MakeRwTypeParam(typeParameter.Name),\n            INamedTypeSymbol namedType => type.SpecialType switch\n            {\n                SpecialType.System_Boolean => \"SpacetimeDB.BSATN.Bool\",\n                SpecialType.System_SByte => \"SpacetimeDB.BSATN.I8\",\n                SpecialType.System_Byte => \"SpacetimeDB.BSATN.U8\",\n                SpecialType.System_Int16 => \"SpacetimeDB.BSATN.I16\",\n                SpecialType.System_UInt16 => \"SpacetimeDB.BSATN.U16\",\n                SpecialType.System_Int32 => \"SpacetimeDB.BSATN.I32\",\n                SpecialType.System_UInt32 => \"SpacetimeDB.BSATN.U32\",\n                SpecialType.System_Int64 => \"SpacetimeDB.BSATN.I64\",\n                SpecialType.System_UInt64 => \"SpacetimeDB.BSATN.U64\",\n                SpecialType.System_Single => \"SpacetimeDB.BSATN.F32\",\n                SpecialType.System_Double => \"SpacetimeDB.BSATN.F64\",\n                SpecialType.System_String => \"SpacetimeDB.BSATN.String\",\n                SpecialType.None => GetTypeInfoForNamedType(namedType),\n                _ => throw new InvalidOperationException(\n                    $\"Unsupported special type {type} ({type.SpecialType})\"\n                ),\n            },\n            IArrayTypeSymbol { ElementType: var elementType } => elementType.SpecialType\n            == SpecialType.System_Byte\n                ? \"SpacetimeDB.BSATN.ByteArray\"\n                : $\"SpacetimeDB.BSATN.Array<{elementType}, {GetTypeInfo(elementType)}>\",\n            _ => throw new InvalidOperationException($\"Unsupported type {type}\"),\n        };\n\n        static string GetTypeInfoForNamedType(INamedTypeSymbol type)\n        {\n            if (type.TypeKind == Microsoft.CodeAnalysis.TypeKind.Error)\n            {\n                throw new UnresolvedTypeException(type);\n            }\n            if (type.TypeKind == Microsoft.CodeAnalysis.TypeKind.Enum)\n            {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-csharp/BSATN.Codegen/Utils.cs#L120-L156","documentation":"GetTypeInfo maps a type symbol's SpecialType to a BSATN name; bool, the numeric types and string are handled explicitly. Any other Roslyn 'special' type — char (System_Char), decimal (System_Decimal), DateTime/DateTimeOffset (System_DateTime), nint/IntPtr — hits the default arm and throws InvalidOperationException, printing the symbol and its SpecialType.","triggerScenarios":"Using char, decimal, DateTime, DateTimeOffset, nint/IntPtr (or other non-None special types) in a table column, reducer argument, or [SpacetimeDB.Type] member of a C# project processed by the BSATN generator.","commonSituations":"C# developers defaulting to DateTime for timestamps and decimal for money; EF/LINQ-style domain models pasted into SpacetimeDB schema types; char fields for single-letter codes.","solutions":["Map to supported primitives: DateTime/DateTimeOffset -> long (unix µs) or the SDK timestamp type if available; decimal -> scaled long or double; char -> string or byte","Replace nint/IntPtr with long","Rebuild — the error is compile-time, so replacing the type clears it immediately"],"exampleFix":"// before\n[SpacetimeDB.Table(Name = \"player\", Public = true)]\npublic partial struct Player {\n    public DateTime CreatedAt;\n    public decimal Balance;\n    public char Rank;\n}\n\n// after\n[SpacetimeDB.Table(Name = \"player\", Public = true)]\npublic partial struct Player {\n    public long CreatedAtMicros;  // unix microseconds\n    public long BalanceMicros;    // scaled fixed-point\n    public string Rank;\n}","handlingStrategy":"validation","validationCode":"// Compile-time by design: `dotnet build` fails while any schema type is unsupported.\n// Checklist to apply to every table/reducer member:\n//   DateTime/DateTimeOffset -> long micros\n//   decimal -> long (scaled) or double\n//   char -> string | byte\n//   nint/IntPtr -> long","typeGuard":null,"tryCatchPattern":"// compile-time error: nothing to catch. Replace the type and rebuild.","preventionTips":["Adopt project-wide conventions mapping BCL types to BSATN primitives","Keep domain models separate from schema types and map explicitly","Build early — the generator reports the exact symbol and SpecialType"],"tags":["csharp","source-generator","bsatn","schema"],"backgroundTag":"codegen-unsupported-type","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}