Skip to content

Codec diagnostics

rebaserHEAD edited this page Oct 25, 2026 · 55 revisions

reference, committed verified 2026-10-24 dev dd9b230

Every diagnostic the codec's source generator reports: when it fires and how severe it is. How a declaration is written is on Codec declarations.

Note

Generated from the source generator's diagnostics at dev dd9b230 by Tools/NexusTomorrow.ProtocolReference. Don't edit it by hand: change the diagnostic's description and regenerate.

The generator refuses to emit code for a type that breaks a rule, and the build fails. A type with any error gets no generated code, and neither does a type that nests or derives from it.

Id Severity When
NTC001 error A wire member has no encoding, isn't a [WireStruct] or [WireMessage] type and isn't [NotOnWire]
NTC002 error A width the member's type can't hold, or outside its range: 1 to 64 bits, a bool only [UInt(1)], a count or a blob length 1 to 32, a [Pad] of at least 1
NTC003 warning, an error in our build An enum member needs more bits than its field declares; the member stays, so a sentinel value that's never sent can be suppressed with its reason, and writing it throws
NTC004 error CountFrom or a union's selector names a member that's missing, declared later, or of the wrong kind, or two unions share one selector
NTC005 error Two messages share an opcode and direction, or two arms share a union value
NTC006 warning, an error in our build [UInt(n)] on a signed integer narrower than its type, so a negative value can't be written; enums are exempt, as NTC003 covers them
NTC007 error Wire members spread across the parts of a partial class, so their order is undefined
NTC008 error The type, or a type containing it, isn't partial
NTC009 error An attribute misused: both or neither of CountBits and CountFrom; a second scalar or string encoding on one member; an encoding that doesn't suit the member's type (a float or string attribute on the wrong type, [SInt] on an unsigned type, [UInt] or [SInt] on a type that isn't an integer, bool or enum, [Blob] off byte[], [Pad] off Pad, [Array] off a List<T> or T[], [FixedArray] off T[]); a [FixedArray] length under 1; a self-counting blob length that isn't whole bytes; a union type that isn't a wire interface or abstract [WireStruct]; an abstract [WireStruct] held as a plain member or as an array element; a nested type holding an aligned blob; a [WireStruct] value type with no setter; a [Count] that isn't a settable non-enum integer or that no array names; a [Blob], [Union], [Array] of T[], scalar or string member with no setter or only an init one (a get-only List<T>, [FixedArray] or [WireStruct] class member is filled in place)
NTC010 error A union type with no arm in the assembly
NTC011 error An aligned blob outside a [WireMessage], the only kind of type that starts on a byte boundary
NTC012 error The type itself is misdeclared: a record, generic or nested in a generic type, both [WireStruct] and [WireMessage], an abstract message, a non-abstract type with no public or internal parameterless constructor, a bad [UnionCase] value, opcode or direction, or a union arm holding an aligned blob
NTC013 error A [UnionCase] value its selector can't carry, so that arm could never be read back
NTC014 error An [Array] Capacity larger than its own count's width can carry, so the bound could never be reached

Each diagnostic sits on its declaration's syntax tree, so .editorconfig severities and #pragma reach it exactly as they reach the compiler's own.

Clone this wiki locally