Table of Contents

Namespace AvroSharp.Serialization

Serialization of the types that the AvroSharp source generator, the avrosharp tool and AvroSharp.CodeGen emit, and the attributes of the attribute-driven generator.

The members that generated code calls are in AvroSharp.Serialization.Generated. That namespace is for generated code, not for direct use, and may change with the generator.

Classes

AvroAliasAttribute

An alias of a record, an enum or a field: the name an earlier version of the schema gave it.

AvroDecimalAttribute

The precision and scale of a decimal member, which Avro's decimal needs.

AvroDefaultAttribute

The field's default, as Avro JSON ("0", ""none"", "[]"): the value a reader gives the field when the data was written without it. A nullable member has null without this attribute.

AvroDocAttribute

The doc of a field or an enum, instead of its XML summary.

AvroEnumDefaultAttribute

Marks the enum member that is the enum's default: the symbol a reader gives a symbol it doesn't know.

AvroFieldPositionAttribute

The field's position among the record's fields, like System.Text.Json's [JsonPropertyOrder] (not Avro's "order", which is the field's sort order). Needed only when the fields are declared in more than one part of a partial type, whose order the compiler doesn't fix; then every field needs it.

AvroFixedAttribute

Makes a byte[] or Guid member a fixed type of Size bytes, instead of bytes or string.

AvroIgnoreAttribute

Leaves a property or field out of the schema.

AvroLogicalTypeAttribute

The logical type of a member, instead of its type's default (timestamp-millis for a DateTimeOffset, which is timestamp-micros by default). On a long, int or string member it annotates the raw value, which the member keeps (the schema gets "avrosharp.logicalType": "raw"): for values .NET's types can't hold.

AvroLogicalValues

Conversions between Avro logical types and .NET types, used by generated serializers and available for the generic model (whose values are the underlying types).

AvroNameAttribute

The Avro name of a field, an enum symbol, or an enum, used as is, without the naming policy.

AvroSerializableAttribute

Generates an Avro schema and serializers for a partial class or record class, with the members that types generated from .avsc files have: Schema, Write, Read, ToAvroBytes, FromAvroBytes and IAvroWritable, IAvroReadable and, on .NET 8 and later, IAvroSerializable<T>. The AvroSharp.Generators package provides the generator.

AvroSerializableDefaultsAttribute

Defaults for every AvroSerializableAttribute type in the assembly, such as [assembly: AvroSerializableDefaults(FieldNames = AvroNaming.CamelCase)]. A type's own settings win.

AvroSerializer

Serializes and deserializes types with generated serializers (IAvroSerializable<TSelf>) in Avro binary encoding, without delegates or reflection.

AvroTypeInfo

A type's Avro schema and its read and write functions, without reflection: from AvroTypes, for code that has only the Type (ReadObject(ref AvroReader) and WriteObject(ref AvroWriter, object?) box values).

AvroTypeInfo<T>

A type's Avro schema and its read and write functions.

AvroTypes

Finds a type's AvroTypeInfo<T> without reflection, so generic code and code that has only a Type can read and write it on every target and under Native AOT. Generated types register themselves from their assembly's module initializer, which runs when code of the assembly first runs, or when one of its types is looked up here (on targets with module initializers, .NET 5 and later; elsewhere call Register<T>(AvroTypeInfo<T>) with the type's AvroTypeInfo). bool, int, long, float, double, string and byte[] are registered with their primitive schemas.

AvroUnionAttribute

Makes an object member a union of the given serializable types (and null when the member is nullable). A value is written as the branch of its runtime type.

Interfaces

IAvroReadable

A value that reads Avro binary data into itself, so one instance can be reused for a sequence of values; every generated record implements it.

IAvroSerializable<TSelf>

A type with generated Avro serializers, as static members, so generic code can read and write it without delegates or reflection (see AvroSerializer). Every record the AvroSharp source generator emits implements it on .NET 8 and later, when the project compiles as C# 11 or later.

IAvroSpecificRecord

Field access by position, implemented by every record type the AvroSharp source generator emits. It follows the contract of Apache.Avro's ISpecificRecord (Schema, Get, Put) without depending on it.

IAvroWritable

A value that writes itself in Avro binary encoding; every generated record implements it.

Enums

AvroNaming

How the attribute-driven generator turns C# member names into Avro field names.

Delegates

AvroReadFunc<T>

Reads one value.

AvroWriteAction<T>

Writes one value.