diff --git a/README.md b/README.md index cd784547..5888cd7a 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@

- - + +

diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 09b131f9..12456657 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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 diff --git a/src/AvroConvert/AvroConvert.csproj b/src/AvroConvert/AvroConvert.csproj index 2899ff92..09a4b818 100644 --- a/src/AvroConvert/AvroConvert.csproj +++ b/src/AvroConvert/AvroConvert.csproj @@ -5,8 +5,7 @@ netstandard2.0;net6.0 10.0 Adrian Strugala - 3.4.3.0 - 3.4.3 + 3.4.4 Rapid Apache Avro serializer for .NET. https://creativecommons.org/licenses/by-nc-sa/3.0/ https://xabe.net/product/avroconvert/ diff --git a/src/AvroConvert/AvroObjectServices/Read/Reader.cs b/src/AvroConvert/AvroObjectServices/Read/Reader.cs index da1e4591..285ed8df 100644 --- a/src/AvroConvert/AvroObjectServices/Read/Reader.cs +++ b/src/AvroConvert/AvroObjectServices/Read/Reader.cs @@ -155,8 +155,8 @@ public string ReadString() else { byte[] bufferArray = ArrayPool.Shared.Rent(length); - Span buffer = bufferArray; - ReadFixed(buffer.Slice(0, length)); + Span buffer = bufferArray.AsSpan()[..length]; + ReadFixed(buffer); string result = System.Text.Encoding.UTF8.GetString(buffer); ArrayPool.Shared.Return(bufferArray); return result; diff --git a/tests/AvroConvertTests/Avro2Json/HeadlessAvro2JsonTests.cs b/tests/AvroConvertTests/Avro2Json/HeadlessAvro2JsonTests.cs index 35191565..641165e4 100644 --- a/tests/AvroConvertTests/Avro2Json/HeadlessAvro2JsonTests.cs +++ b/tests/AvroConvertTests/Avro2Json/HeadlessAvro2JsonTests.cs @@ -1,5 +1,8 @@ using Newtonsoft.Json; using SolTechnology.Avro; +using System.Buffers; +using System.IO; +using System.Text; using Xunit; namespace AvroConvertComponentTests.Avro2Json @@ -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.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.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); }