Prowl.Echo separates the serialization of .NET objects intoDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ProwlEngine/Prowl.Echo/llms.txt
Use this file to discover all available pages before exploring further.
EchoObject trees from the encoding of those trees into bytes or text. The file format layer handles the second step. Six built-in IFileFormat implementations cover the most common encoding targets: a compact proprietary binary format, a human-readable proprietary text format, JSON, BSON, YAML, and XML. All six expose a static Instance singleton and implement the IFileFormat interface, so every extension method from FileFormatExtensions works with all of them. This page also documents TypeNameRegistry, the auxiliary API that controls how type names are compacted and resolved during serialization.
EchoBinaryFormat
EchoBinaryFormat is the recommended format when file size and read/write speed matter more than human readability. It preserves all EchoObject types exactly during a roundtrip — no precision is lost for any numeric type. Internally it uses LZW compression on string keys when Size mode is selected.
BinarySerializationOptions
Controls the integer encoding strategy used for all integer-typed
EchoObject values.BinaryEncodingMode
| Value | Description |
|---|---|
Performance | Fixed-width integer encoding. Faster read/write; larger output. This is the default. |
Size | LEB128 variable-length integer encoding plus LZW compression for string keys. Smaller output; slightly slower. |
Usage
EchoTextFormat
EchoTextFormat is Prowl.Echo’s native human-readable text format. Like EchoBinaryFormat, it preserves all EchoObject types exactly during a roundtrip — every numeric suffix and tag type is encoded explicitly, so no precision is lost. It is the best choice when you need a text file that can be diffed in version control without any loss of fidelity.
{ } for compounds and [ ] for lists, with type-suffix notation for numeric values (e.g., 42 is int, 42L is long, 3.14F is float).
Usage
EchoObject.WriteToString() and EchoObject.ReadFromString() are direct static methods on EchoObject defined in EchoObject.cs and use EchoTextFormat internally. They are distinct from the IFileFormat extension methods of the same name, which accept any IFileFormat as the receiver.JsonFileFormat
JsonFileFormat writes standard, dependency-free JSON and can read both Echo-produced JSON and generic JSON from any other source. Because JSON has fewer numeric types than EchoObject, some type precision is lost on roundtrip: byte and short round-trip as int, float round-trips as double, and ByteArray values are Base64-encoded strings. Use EchoTextFormat or EchoBinaryFormat if exact type preservation is required.
EchoObject exposes two shortcut methods that delegate to JsonFileFormat.Instance:
Usage
BsonFileFormat
BsonFileFormat implements the BSON specification with no external dependencies. BSON is a binary encoding of JSON-like documents, useful when you need binary output but also interoperability with MongoDB or other BSON consumers. Type precision losses are similar to JSON: byte/short become int32, float becomes double, and decimal is stored as a string to preserve precision.
EchoObject exposes two shortcut methods that delegate to BsonFileFormat.Instance:
BSON requires a document at the top level. When you pass a non-Compound
EchoObject to WriteTo or WriteToBson, the format automatically wraps it in a single-key document with the key __echo_wrapped_value__ and unwraps it transparently on read.Usage
YamlFileFormat
YamlFileFormat writes clean, human-readable YAML and can parse both Echo-produced YAML and generic YAML from other tools. Implemented without external dependencies. Type precision is reduced similarly to JSON: numeric types resolve to int, long, or double on read, and ByteArray values are encoded using the !!binary tag. Use EchoTextFormat or EchoBinaryFormat for lossless roundtrips.
EchoObject exposes two shortcut methods that delegate to YamlFileFormat.Instance:
Usage
XmlFileFormat
XmlFileFormat writes well-formed XML with explicit type attributes that preserve all EchoObject types during a roundtrip. It can also read generic XML that lacks type attributes, in which case it infers types from the text content. Implemented without external dependencies.
<?xml version="1.0" encoding="utf-8"?>) and wraps the root EchoObject in an <echo> element. Compound keys that are not valid XML element names are sanitized, with the original key preserved in a key attribute.
EchoObject exposes two shortcut methods that delegate to XmlFileFormat.Instance:
Usage
FileFormatExtensions
FileFormatExtensions is a static class providing convenience extension methods that wrap IFileFormat.WriteTo and IFileFormat.ReadFrom. These methods are available on every IFileFormat — including your own custom implementations.
| Method | Returns | Notes |
|---|---|---|
WriteToString(tag) | string | Encodes via a MemoryStream and reads back with UTF-8. Best for text formats. |
ReadFromString(input) | EchoObject | Converts the string to UTF-8 bytes, then calls ReadFrom. |
WriteToBytes(tag) | byte[] | Writes to a MemoryStream and returns its buffer. Works for any format. |
ReadFromBytes(data) | EchoObject | Wraps data in a MemoryStream and calls ReadFrom. |
WriteToFile(tag, path) | void | Creates or overwrites the file at path. |
ReadFromFile(path) | EchoObject | Opens the file at path for reading. |
TypeNameRegistry
TypeNameRegistry manages the compact and full type-name mappings that Echo writes into EchoObject compounds when preserving polymorphic type information. It caches all lookups in thread-safe concurrent dictionaries for performance.
Methods
Returns the shortest possible name for a type. For the predefined primitives this is a single-character or two-character alias. For enums it is
e:EnumName. For arrays it is elementName[] or elementName[,] for multi-dimensional arrays. For generic types it is TypeName<argName1,argName2>. For everything else it falls back to Type.Name.Resolves a compact name back to a
Type. Returns null if resolution fails.Returns the assembly-qualified name (
Type.AssemblyQualifiedName), falling back to FullName and then Name if the qualified name is unavailable.Resolves an assembly-qualified name via
Type.GetType, falling back to a reflection scan of all loaded assemblies. Returns null on failure.Evicts all entries from the compact-name, full-name, and lookup caches. Call this if you hot-reload assemblies or otherwise change the set of types visible to reflection.
Predefined compact names
The following compact aliases are built intoTypeNameRegistry and do not require any registration:
| .NET type | Compact name |
|---|---|
int | "i" |
string | "s" |
bool | "b" |
float | "f" |
double | "d" |
long | "l" |
byte | "y" |
sbyte | "Y" |
short | "h" |
ushort | "H" |
uint | "I" |
ulong | "L" |
decimal | "m" |
char | "c" |
DateTime | "dt" |
Guid | "g" |