Namespace CStructSharp
Classes
- CStruct
Compiles a C-like layout definition and uses it to read, inspect, write, or update binary data. Create one instance per layout, then reuse it for sequential or concurrent operations. Concurrent calls must use distinct streams, payload graphs, and other mutable resources, or the caller must synchronize each shared resource for the complete operation.
- CStructCompilationOptions
Controls the resource limits applied before a C-like layout definition is parsed and compiled.
- CStructLayoutAttribute
Asks the CStructSharp source generator to turn a layout into C# at compile time: one class per struct and union, an enum per layout enum, and straight-line
Parse,Serialize,Update, andResolveAddressmethods on the attributedstatic partialclass, with the same results and the same diagnostics as CStruct produces for the same definition and options.
- CStructMappedAttribute
Asks the CStructSharp source generator to implement ICStructMapped<TSelf> for a
partialclass:ReadFromandWriteToassign the class's public members by name, with the conversions Get<T>(string) applies, and a module initializer registers the type with MappedTypes.
- CStructMemberAttribute
Names the layout member a property or field of a
[CStructMapped]class maps to, when the C# name differs.
- MappedTypes
The registry of classes that implement ICStructMapped<TSelf>. Registration captures the type's static mapping members as delegates once, under the generic constraint, so the read and write paths can map an instance from its Type alone - no reflection, and therefore no trimming or Native AOT conventions. Generated mappers register themselves in a module initializer; a hand-written mapper does the same, or calls Register<T>() once at startup (registering twice is harmless).
- ReadOptions
Controls the safety budgets and pointer policy shared by parsing, debug parsing, selected reads, address resolution, and dynamic-length lookup.
- StaticHelpers
Contains small conversion helpers shared by examples, tests, and callers.
- UpdateOptions
Adds bounded read-side traversal and in-place replacement choices to the normal write options. Updates validate against sparse staging before commit and cannot extend the existing destination stream.
- WriteOptions
Controls serialization and stream-writing operations performed by CStruct.
Interfaces
- ICStructGenerated<TSelf>
Implemented by the root class the
[CStructLayout]generator emits, so generic code can accept any generated root: the runtime CStruct for the same layout, the root name, and the generated span operations.
- ICStructMapped<TSelf>
A class that maps to and from a layout composite without reflection: ReadFrom(StructValue) builds an instance from a parsed StructValue and WriteTo(TSelf, StructValue) fills a StructValue of the layout's shape from an instance. The
[CStructMapped]source generator writes both members for apartialclass; a class may also implement them by hand. Register<T>() makes the type known to ReadValue<T>(Stream, string?, IReadOnlyDictionary<string, int>?, ReadOptions?), Get<T>(string), and the write operations. Register from a module initializer ([ModuleInitializer] internal static void Register() => MappedTypes.Register<Point>();), as generated code does: a module initializer runs before any other code in the assembly on every runtime, Native AOT included, whereas a static constructor that nothing else triggers is removed by the AOT compiler.
Enums
- BitfieldAllocation
Which end of a storage unit the first bitfield takes.
- BitfieldPacking
Selects which C compiler family's rule places adjacent bitfields of different declared types.
- PointerAddressingMode
Lists how pointer addresses in the input stream should be interpreted.
- UnknownMemberPolicy
Says what a write does with a supplied member that the layout does not declare.