Table of Contents

Class CodeGenOptions

Namespace
AvroSharp.CodeGen
Assembly
AvroSharp.CodeGen.dll

Options for CSharpCodeGenerator.

public sealed class CodeGenOptions
Inheritance
CodeGenOptions
Inherited Members

Properties

ApacheCompatible

Gets whether generated types also work with Apache.Avro's specific API (SpecificDatumWriter/Reader): records implement Avro.Specific.ISpecificRecord, fixed types derive from Avro.Specific.SpecificFixed, and logical types use Apache's .NET types (DateTime for dates and timestamps, TimeSpan for times, Guid for string UUIDs, Avro.AvroDecimal for decimals), whatever LogicalTypes says. The generated code then needs a reference to Apache.Avro. Defaults to false.

Default

Gets the default options.

LanguageVersion

Gets the major C# version the generated code may use. With 11 or later it adds, for .NET 8 and later, IAvroSerializable<T>. It must be 7 or later. Defaults to 14.

LogicalTypes

Gets how values of logical types are represented. Defaults to Native.

Namespace

Gets the C# namespace for named types that have no Avro namespace. Defaults to null: such types are generated in the global namespace.

NamespaceMap

Gets C# namespaces for Avro namespaces, as Apache.Avro's avrogen maps them with --namespace avro:csharp. A type's namespace is replaced by the longest key that equals it or is a prefix of it at a .: with com.example mapped to Example, com.example.events becomes Example.events. Only the C# namespace changes; the schema, and so the data and fingerprints, do not. Not supported with ApacheCompatible, since Apache.Avro finds generated types by the schema's full name. Defaults to null: no mapping.

NullableAnnotations

Gets whether to emit nullable reference type annotations (string?, #nullable enable), which need C# 8 or later. Without them the generated code compiles as C# 7.3, the default for netstandard2.0 and .NET Framework projects. Defaults to true; with a LanguageVersion below 8 it must be false, or generation throws ArgumentException.

PropertyNames

Gets how record fields become property names, or null (the default) for the mode's own: PascalCase, or with ApacheCompatible Avro, the names Apache.Avro's avrogen uses.

TargetHasDateOnly

Gets whether the target framework has System.DateOnly and System.TimeOnly (.NET 6 and later). When it does not, date maps to DateTime and time-* to TimeSpan. Defaults to true.

See Also