AvroConvert 1.8.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AvroConvert --version 1.8.0                
NuGet\Install-Package AvroConvert -Version 1.8.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AvroConvert" Version="1.8.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AvroConvert --version 1.8.0                
#r "nuget: AvroConvert, 1.8.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AvroConvert as a Cake Addin
#addin nuget:?package=AvroConvert&version=1.8.0

// Install AvroConvert as a Cake Tool
#tool nuget:?package=AvroConvert&version=1.8.0                

Nuget Github

AvroConvert

Avro format combines readability of JSON format and compression of binary data serialization. <br></br>

The main purpose of the project was to enhance communication between microservices. Replacing JSON with Avro brought two main benefits:

  • Reduced amount of data send via HTTP by about 30%
  • Increased communication security - the data was not visible in plain JSON text

Documentation

General information: http://avro.apache.org/ <br></br> Wiki: https://cwiki.apache.org/confluence/display/AVRO/Index

Code samples

Serialization
 byte[] avroObject = AvroConvert.Serialize(object yourObject);
Deserialization

Deserialization to known type

CustomClass deserializedObject = AvroConvert.Deserialize<CustomClass>(byte[] avroObject);

Deserialization to map of property names and values

Dictionary<string, object> mapOfPropertiesAndValues = AvroConvert.Deserialize(byte[] avroObject);  

Deserialization when a property value is null, but schema contains information about default value

//Model used for serialization
public class DefaultValueClass
{
    [DefaultValue("Let's go")]
    public string justSomeProperty { get; set; }

    [DefaultValue(2137)]
    public long? andLongProperty { get; set; }
}

//Deserializing object with null data
 DefaultValueClass deserializedObject = AvroConvert.Deserialize<DefaultValueClass>(byte[] avroObject);

//Produces following object:
> deserializedObject.justSomeProperty
> "Let's go"

> deserializedObject.andLongProperty
> 2137

#### Generating Avro schema for C# classes

Using simple class
```csharp

//Model
public class SimpleTestClass
{
	public string justSomeProperty { get; set; }

	public long andLongProperty { get; set; }
}


//Action
string schemaInJsonFormat = AvroConvert.GenerateSchema(typeof(SimpleTestClass));


//Produces following schema:
"{"type":"record","name":"AvroConvert.SimpleTestClass","fields":[{"name":"justSomeProperty","type":["null","string"]},{"name":"andLongProperty","type":"long"}]}"

Using class decorated with attributes

//Model
[DataContract(Name = "User", Namespace = "user")]
public class AttributeClass
{
	[DataMember(Name = "name")]
	public string StringProperty { get; set; }

	[DataMember(Name = "favorite_number")]
	[NullableSchema]
	public int? NullableIntProperty { get; set; }

	[DataMember(Name = "favorite_color")]
	public string AndAnotherString { get; set; }
}


//Action
string schemaInJsonFormat = AvroConvert.GenerateSchema(typeof(AttributeClass));


//Produces following schema:
"{"type":"record","name":"user.User","fields":[{"name":"name","type":["null","string"]},{"name":"favorite_number","type":["null","int"]},{"name":"favorite_color","type":["null","string"]}]}"
Reading Avro schema from Avro encoded object
  string schemaInJsonFormat = AvroConvert.GetSchema(byte[] avroObject)

Contribution

We want to improve AvroConvert as much as possible. If you have any idea, found next possible feature, optimization opportunity or better way for integration, leave a comment or pull request.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on AvroConvert:

Package Downloads
SolTechnology.Avro.Kafka

Library containing extensions for Confluent Kafka platform

Memphis.Client

Memphis.Client SDK intended to make easy integration of Memphis into .NET projects

SolTechnology.Avro.Http

Library containing functionalities, which enable communication between microservices using Avro data format

OptimoveSdk.Engager.Integration

SDK for Engagers intergration with Optimove

SolTechnology.Core.ApiClient

SolTechnology Core API client library

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on AvroConvert:

Repository Stars
AdrianStrugala/AvroConvert
Rapid Avro serializer for C# .NET
Version Downloads Last updated
3.4.10 3,171 10/21/2024
3.4.9 23,287 9/18/2024
3.4.8 59,251 5/8/2024
3.4.7 2,601 4/26/2024 3.4.7 is deprecated because it has critical bugs.
3.4.6 28,362 3/4/2024
3.4.5 6,572 2/15/2024
3.4.4 14,168 1/16/2024
3.4.3 78,567 12/9/2023
3.4.2 7,441 12/1/2023
3.4.1 12,992 11/11/2023
3.4.0 25,239 9/18/2023
3.3.7 17,414 8/7/2023
3.3.6 35,107 5/29/2023
3.3.5 7,963 5/11/2023
3.3.4 57,838 3/3/2023
3.3.3 583 2/28/2023
3.3.2 21,281 2/6/2023
3.3.1 2,958 1/27/2023
3.3.0 102,230 10/11/2022
3.2.9 76,100 6/22/2022
3.2.8 2,237 6/1/2022
3.2.7 2,114 5/23/2022
3.2.6 825 5/16/2022
3.2.5 61,383 4/13/2022
3.2.4 841 4/10/2022
3.2.3 29,817 10/29/2021
3.2.2 27,621 10/2/2021
3.2.1 1,063 9/29/2021
3.2.0 4,571 9/14/2021
3.1.5 24,579 8/30/2021
3.1.4 5,575 8/12/2021
3.1.3 6,317 8/2/2021
3.1.2 4,375 6/24/2021
3.1.1 1,165 6/14/2021
3.1.0 24,793 5/15/2021
3.0.1 6,388 4/2/2021
3.0.0 24,629 3/26/2021
2.7.1 54,866 2/5/2021
2.7.0 34,605 12/18/2020
2.6.3 3,119 10/25/2020
2.6.2 502 10/23/2020
2.6.1 4,053 7/25/2020
2.6.0 587 7/22/2020
2.5.1 1,443 6/11/2020
2.5.0 16,770 5/15/2020
2.4.1 1,458 4/14/2020
2.4.0 972 3/25/2020
2.3.0 801 3/19/2020
2.2.2 1,105 2/7/2020
2.2.1 588 2/7/2020
2.2.0 683 1/27/2020
2.1.0 575 1/16/2020
2.0.0 570 1/4/2020
1.8.1 857 12/9/2019
1.8.0 3,370 8/30/2019
1.7.0 629 8/22/2019
1.6.0 651 7/22/2019
1.5.1 761 7/14/2019
1.5.0 757 7/11/2019
1.4.0 619 6/17/2019
1.3.0 661 6/4/2019
1.2.0 721 6/3/2019
1.1.0 673 5/28/2019
1.0.1 758 5/21/2019
1.0.0 1,010 4/24/2019
0.8.0 980 5/1/2019
0.7.0 1,064 4/22/2019
0.6.3 960 4/19/2019
0.6.2 977 4/19/2019
0.6.1 949 4/19/2019
0.6.0 959 4/19/2019
0.5.0 1,065 4/18/2019
0.3.0 1,210 4/11/2019
0.2.1 995 4/11/2019
0.2.0 987 4/11/2019
0.1.0 1,085 4/10/2019