{"record":{"id":"4be800cdbc10c8da","repo":"clockworklabs/SpacetimeDB","slug":"invalidtablevisibility","errorCode":"InvalidTableVisibility","errorMessage":"Table row type visibility must be public or internal, including containing types.","messagePattern":"Table row type visibility must be public or internal, including containing types\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"crates/bindings-csharp/Codegen/Module.cs","lineNumber":536,"sourceCode":"\n        var container = context.TargetSymbol;\n        Visibility = container.DeclaredAccessibility;\n        while (container != null)\n        {\n            switch (container.DeclaredAccessibility)\n            {\n                case Accessibility.ProtectedAndInternal:\n                case Accessibility.NotApplicable:\n                case Accessibility.Internal:\n                case Accessibility.Public:\n                    if (Visibility < container.DeclaredAccessibility)\n                    {\n                        Visibility = container.DeclaredAccessibility;\n                    }\n                    break;\n                default:\n                    diag.Report(ErrorDescriptor.InvalidTableVisibility, typeSyntax);\n                    throw new Exception(\n                        \"Table row type visibility must be public or internal, including containing types.\"\n                    );\n            }\n\n            container = container.ContainingType;\n        }\n\n        TableAccessors = new(\n            context.Attributes.Select(a => new TableAccessor(this, a, diag)).ToImmutableArray()\n        );\n        Indexes = new(\n            context\n                .TargetSymbol.GetAttributes()\n                .Where(TableIndex.CanParse)\n                .Select(a => new TableIndex(this, a, diag))\n                .ToImmutableArray()\n        );\n    }","sourceCodeStart":518,"sourceCodeEnd":554,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/3653d2ed498fddbd83b7062aa6bf8970e18635ec/crates/bindings-csharp/Codegen/Module.cs#L518-L554","documentation":"Compile-time error from the SpacetimeDB C# module source generator. When scanning a [Table] row type, Module.cs walks the type and all its containing types and only accepts Accessibility.Public, Internal, ProtectedAndInternal or NotApplicable; any private/protected/protected-or-internal nesting level makes the generator report InvalidTableVisibility and throw, aborting code generation. The row type must be at least as visible as every containing type.","triggerScenarios":"Putting [Table]/[Table(name, public=true)] on a private nested class, a protected nested class, or a public class nested inside a private class; declaring the row type with `internal` inside a `private` outer type also fails because Visibility must be raised to the container's accessibility.","commonSituations":"New module projects keeping tables nested inside a Program/Module helper class marked private; refactoring that moves tables into internal helper classes; copying sample code where the enclosing class lost its public modifier; Unity-style file-scoped nesting habits applied to SpacetimeDB modules.","solutions":["Make the [Table] row type `public` (simplest and always accepted)","If it is nested, make every containing class `public` or `internal` as well","Rebuild after the change so the source generator re-runs and emits the table boilerplate"],"exampleFix":"// before\npublic static class Module {\n    [Table]\n    private class Player { public uint Id; } // InvalidTableVisibility\n}\n\n// after\npublic static class Module {\n    [Table]\n    public class Player { public uint Id; }\n}","handlingStrategy":"validation","validationCode":"// Check before adding [Table]: row type and all containers must be public/internal\nstatic bool IsTableVisible(Type t)\n{\n    for (var c = t; c is not null; c = c.DeclaringType)\n        if (c.IsNestedPrivate || c.IsNestedFamily || c.IsNestedFamORAssem)\n            return false; // private / protected / protected-or-internal are rejected\n    return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default to `public` for all [Table] row types and their containing classes","Keep STDB generator diagnostics visible in the build (don't suppress STDB analyzers)","Watch the IDE error list, not just compiler output — the generator reports before it throws"],"tags":["csharp","code-generation","roslyn","table","visibility","spacetimedb-module"],"backgroundTag":"codegen-type-visibility","analyzedSha":"3653d2ed498fddbd83b7062aa6bf8970e18635ec","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}