Skip to content

AvroConvert 4.0.0

Latest

Choose a tag to compare

@github-actions github-actions released this 11 Nov 21:37
· 10 commits to master since this release
fafc319

Breaking changes:

  • Requires .NET 10; for .NET Framework and .NET 6–9 use 3.4.x (release/3.x, security and critical fixes)
  • New licence: PolyForm Noncommercial / PolyForm Small Business, commercial licence for larger organisations (https://soltechnology.dev/avroconvert)
  • Collections written as one container entry per item, like other Avro tools (#118); 3.x files still read; old layout: CollectionMode = SingleArray
  • Header-only file deserializes to an empty collection instead of null
  • Missing non-nullable field throws instead of returning default (#87); old behaviour: MissingFieldHandling = UseDefault
  • null written into a non-nullable field throws instead of writing an empty value (#87); old behaviour: NullValueHandling = WriteEmpty
  • null in the data is read as null also for a field with [DefaultValue]; the default applies only to a missing field
  • Items and values annotated as nullable (List<string?>, string?[], Dictionary<string, string?>) get the schema ["null", T]; Schema Registry accepts it in BACKWARD mode, not in FORWARD / FULL
  • [DefaultValue] of an enum member written as the symbol instead of the number
  • Avro2Json, Json2Avro and schema defaults ignore JsonConvert.DefaultSettings
  • DeserializeHeadless<List<T>> and DeserializeHeadless(bytes, writer, reader, type) read all rows instead of the first one (#69)
  • Read objects created with the public parameterless constructor; a field missing in the data keeps its initialiser
  • DateTimeOffset written as its UTC instant instead of the wall-clock time
  • Snappy blocks include the CRC-32 required by the specification
  • Generated schemas differ, data stays compatible: names of generic records (#159), time-micros, non-public [DataMember] members (#51), IDictionary<string, T> / IReadOnlyDictionary<string, T> as maps
  • Multidimensional arrays (int[,]) throw; use jagged arrays (#26)
  • SchemaConvert removed; use AvroSchema (#73)
  • Numbers read into dynamic follow the reader schema type; unknown logicalType read as its underlying type
  • Deserialize(bytes, type) and DeserializeHeadless(bytes, …, type) throw the exception of the call instead of TargetInvocationException
  • Reflection-based methods marked [RequiresUnreferencedCode] / [RequiresDynamicCode]
  • GenerateModel output: DateOnly / TimeOnly, using directives, #nullable enable annotations, attributes that keep the schema ([DataContract], [AvroType], [AvroDecimal], [AvroFixed], [AvroUnion], [Description])
  • SolTechnology.Avro.Kafka rewritten on Confluent.SchemaRegistry 2.16 (wire format, schema evolution, references, subject name strategies); removed KafkaConsumer, KafkaPropNames, ConfluentSchema
  • SolTechnology.Avro.Http follows System.Net.Http.Json (GetFromAvroAsync, PostAsAvroAsync, ReadFromAvroAsync…), Minimal API results, streaming; old names [Obsolete]
  • Code compiled against a 4.0 preview must be rebuilt

Changes:

  • Serialization and deserialization compiled per schema and type: several times faster, fewer allocations
  • Added SolTechnology.Avro.Cli (avroconvert): induce, compile, tojson, getschema, canonical, fingerprint, compat, registry
  • Added streaming: Serialize<T>(IEnumerable<T> / IAsyncEnumerable<T>, Stream), Deserialize<T>(Stream) returning IAsyncEnumerable<T>, output to IBufferWriter<byte>
  • One way to pass a schema (AvroSchema) and a codec (AvroConvertOptions); overloads taking schema text, CodecType or a file path hidden from IntelliSense, to be removed in the next major version
  • Added AvroSchema (#73): Parse (also with referenced schemas), Create, FromAvro, FromValue, FromItems, InferFromJson, canonical form, fingerprints, Compare, CheckCompatibility
  • Added Avro2JsonEncoding / JsonEncoding2Avro: JSON Encoding of the Avro specification (#156)
  • Added logical types timestamp-nanos, local-timestamp-*, big-decimal, uuid on fixed; AvroConvertOptions.DateTimeRepresentation (#153)
  • Added zstandard codec
  • Added support for recursive types
  • Added support for ExpandoObject (#112), DeserializeHeadless<dynamic> (#107) and unions of records read into object / dynamic (#174)
  • Added reading records into Dictionary<string, object> (#197)
  • Added support for map keys convertible from string (Dictionary<Uri, T>) and dictionary types other than Dictionary<,>
  • Added Serialize overloads taking an AvroSchema, header metadata and AvroConvert.GetMetadata (#196)
  • Added Deserialize(byte[], Type, options), DeserializeHeadless<T>(ReadOnlySpan<byte>, …), Json2Avro(json, options); DeserializeHeadless takes reader schema, options, numberOfRows and a runtime type
  • [AvroFixed] public: a byte[] as a named fixed; on a decimal, a decimal on fixed
  • null in [AvroUnion] sets the position of the null branch: [AvroUnion(typeof(int), null)] int? → ["int", "null"]
  • Avro2Json(file, schema) resolves the data to the given schema as a reader schema
  • Values of type object (Dictionary<string, object>, object members, List<object>, ExpandoObject) take their schema from the written values
  • Serialize<object>(items) writes items of different types as a union
  • Union branch chosen by the exact type of the value first; a dictionary, ExpandoObject or JObject goes to the record that takes all its keys
  • Writing with a given schema fills fields missing in the value with their defaults
  • Schema resolution: string ↔ bytes promotion, field and record aliases, union records matched by name or alias
  • Schemas keep attributes the specification does not define (e.g. Iceberg field-id), unknown logical types and enum aliases
  • Reads files of Apache.Avro for C# with a logical type on a fixed or an enum
  • DateTime reads and writes date, TimeSpan time-millis / time-micros (Apache.Avro avrogen classes); dates in string fields as ISO 8601 text (Chr.Avro)
  • GenerateModel classes give back the source schema; supports fixed, unions of any branches, nested arrays and maps, C# keywords, defaults, several schemas in one file
  • Deep data, schemas without an end and reference cycles throw instead of ending the process with a stack overflow
  • Optional licence declaration: AvroConvert.License or AVROCONVERT_LICENSE
  • Fix for Merge losing data after the first block; Merge keeps the writer schema, rejects files with different schemas, reads SingleArray files
  • Fix for OpenDeserializer<ExpandoObject> and for empty arrays in OpenDeserializer
  • Fix for GetSchema(path) on read-only and locked files
  • Fix for one-element and nested collections (List<List<T>>)
  • Fix for NamingPolicy on deserialization
  • Fix for MemoryStream not disposed in SerializeHeadless (#163)
  • Dependencies: Newtonsoft.Json, IronSnappy, ZstdSharp.Port