Skip to content

Commit

Permalink
Release 3.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianStrugala committed Jan 16, 2024
1 parent bb8a201 commit fe08cf0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</p>

<p align="center">
<a href="https://www.nuget.org/packages/AvroConvert"><img src="https://img.shields.io/badge/Nuget-v3.4.3-blue?logo=nuget"></a>
<a href="https://adrianstrugala.github.io/AvroConvert/"><img src="https://img.shields.io/badge/Downloads-555k-blue?logo=github"></a>
<a href="https://www.nuget.org/packages/AvroConvert"><img src="https://img.shields.io/badge/Nuget-v3.4.4-blue?logo=nuget"></a>
<a href="https://adrianstrugala.github.io/AvroConvert/"><img src="https://img.shields.io/badge/Downloads-582k-blue?logo=github"></a>
<a href="https://github.com/AdrianStrugala/AvroConvert/actions/workflows/build&test.yml"><img src="https://github.com/AdrianStrugala/AvroConvert/actions/workflows/build&test.yml/badge.svg"></a>

</p>
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**v. 3.4.4 (16.01.24)**
- Add support for EnumMember attribute

\
**v. 3.4.3 (09.12.23)**
- Fix for caching of skippers during deserialization
- Fix for deserialization of enums marked with flags
Expand Down
3 changes: 1 addition & 2 deletions src/AvroConvert/AvroConvert.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<Authors>Adrian Strugala</Authors>
<AssemblyVersion>3.4.3.0</AssemblyVersion>
<Version>3.4.3</Version>
<Version>3.4.4</Version>
<Description>Rapid Apache Avro serializer for .NET.</Description>
<PackageLicenseUrl>https://creativecommons.org/licenses/by-nc-sa/3.0/</PackageLicenseUrl>
<PackageProjectUrl>https://xabe.net/product/avroconvert/</PackageProjectUrl>
Expand Down
4 changes: 2 additions & 2 deletions src/AvroConvert/AvroObjectServices/Read/Reader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ public string ReadString()
else
{
byte[] bufferArray = ArrayPool<byte>.Shared.Rent(length);
Span<byte> buffer = bufferArray;
ReadFixed(buffer.Slice(0, length));
Span<byte> buffer = bufferArray.AsSpan()[..length];
ReadFixed(buffer);
string result = System.Text.Encoding.UTF8.GetString(buffer);
ArrayPool<byte>.Shared.Return(bufferArray);
return result;
Expand Down
35 changes: 35 additions & 0 deletions tests/AvroConvertTests/Avro2Json/HeadlessAvro2JsonTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Newtonsoft.Json;
using SolTechnology.Avro;
using System.Buffers;
using System.IO;
using System.Text;
using Xunit;

namespace AvroConvertComponentTests.Avro2Json
Expand Down Expand Up @@ -125,6 +128,38 @@ public void Avro2Json_ConvertArray_ProducedDesiredJson()
var resultJson = AvroConvert.Avro2Json(avroSerialized, schema);


//Assert
Assert.Equal(expectedJson, resultJson);
}

[Fact]
public void Avro2Json_ConvertLongString_ProducedDesiredJson()
{
//Arrange

// We first use an ArrayPool for something completely unrelated
byte[] bufferArray = ArrayPool<byte>.Shared.Rent(2048);
var s = "I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. secret string";
using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(s)))
{
stream.Read(bufferArray, 0, s.Length);
}
ArrayPool<byte>.Shared.Return(bufferArray);


// We then use it in AvroConvert. We must have a string of >512 bytes.
var @string = "I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. I am long the serialization string. ";

var expectedJson = JsonConvert.SerializeObject(@string);

var schema = AvroConvert.GenerateSchema(@string.GetType());
var avroSerialized = AvroConvert.SerializeHeadless(@string, schema);


//Act
var resultJson = AvroConvert.Avro2Json(avroSerialized, schema);


//Assert
Assert.Equal(expectedJson, resultJson);
}
Expand Down

0 comments on commit fe08cf0

Please sign in to comment.