Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to KNet 2.5.0 #218

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/net/Common/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Owners>MASES s.r.l.</Owners>
<Authors>MASES s.r.l.</Authors>
<Company>MASES s.r.l.</Company>
<Version>2.0.2.0</Version>
<Version>2.1.0.0</Version>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MASES.KNet.Serialization.Avro" Version="2.4.3" />
<PackageReference Include="MASES.KNet.Serialization.Avro" Version="2.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
62 changes: 31 additions & 31 deletions src/net/KEFCore.SerDes.Avro/AvroKEFCoreSerDes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
namespace MASES.EntityFrameworkCore.KNet.Serialization.Avro;

/// <summary>
/// Avro base class to define extensions of <see cref="KNetSerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// Avro base class to define extensions of <see cref="SerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// </summary>
public static class AvroKEFCoreSerDes
{
Expand All @@ -45,21 +45,21 @@ public static class AvroKEFCoreSerDes
/// </summary>
public static readonly Type DefaultValueContainer = typeof(AvroValueContainer<>);
/// <summary>
/// Base class to define key extensions of <see cref="KNetSerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// Base class to define key extensions of <see cref="SerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// </summary>
public static class Key
{
/// <summary>
/// Avro Key Binary encoder extension of <see cref="KNetSerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// Avro Key Binary encoder extension of <see cref="SerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// </summary>
/// <typeparam name="T"></typeparam>
public class Binary<T> : KNetSerDes<T>
public class Binary<T> : SerDes<T>
{
readonly byte[] keyTypeName = Encoding.UTF8.GetBytes(typeof(T).FullName!);
readonly byte[] keySerDesName = Encoding.UTF8.GetBytes(typeof(Binary<>).ToAssemblyQualified());
readonly SpecificDefaultWriter SpecificWriter = new(AvroKeyContainer._SCHEMA);
readonly SpecificDefaultReader SpecificReader = new(AvroKeyContainer._SCHEMA, AvroKeyContainer._SCHEMA);
readonly IKNetSerDes<T> _defaultSerDes = default!;
readonly ISerDes<T> _defaultSerDes = default!;
/// <inheritdoc/>
public override bool UseHeaders => true;
/// <summary>
Expand All @@ -69,20 +69,20 @@ public Binary()
{
if (KNetSerialization.IsInternalManaged<T>())
{
_defaultSerDes = new KNetSerDes<T>();
_defaultSerDes = new SerDes<T>();
}
else if (!typeof(T).IsArray)
{
throw new InvalidOperationException($"{typeof(Binary<>).ToAssemblyQualified()} cannot manage {typeof(T).Name}, override or build a new serializaer");
}
}

/// <inheritdoc cref="KNetSerDes{T}.Serialize(string, T)"/>
/// <inheritdoc cref="SerDes{T, TJVM}.Serialize(string, T)"/>
public override byte[] Serialize(string topic, T data)
{
return SerializeWithHeaders(topic, null!, data);
}
/// <inheritdoc cref="KNetSerDes{T}.SerializeWithHeaders(string, Headers, T)"/>
/// <inheritdoc cref="SerDes{T, TJVM}.SerializeWithHeaders(string, Headers, T)"/>
public override byte[] SerializeWithHeaders(string topic, Headers headers, T data)
{
headers?.Add(KNetSerialization.KeyTypeIdentifier, keyTypeName);
Expand All @@ -101,12 +101,12 @@ public override byte[] SerializeWithHeaders(string topic, Headers headers, T dat
SpecificWriter.Write(container, encoder);
return memStream.ToArray();
}
/// <inheritdoc cref="KNetSerDes{T}.Deserialize(string, byte[])"/>
/// <inheritdoc cref="SerDes{T, TJVM}.Deserialize(string, byte[])"/>
public override T Deserialize(string topic, byte[] data)
{
return DeserializeWithHeaders(topic, null!, data);
}
/// <inheritdoc cref="KNetSerDes{T}.DeserializeWithHeaders(string, Headers, byte[])"/>
/// <inheritdoc cref="SerDes{T, TJVM}.DeserializeWithHeaders(string, Headers, byte[])"/>
public override T DeserializeWithHeaders(string topic, Headers headers, byte[] data)
{
if (_defaultSerDes != null) return _defaultSerDes.DeserializeWithHeaders(topic, headers, data);
Expand All @@ -120,16 +120,16 @@ public override T DeserializeWithHeaders(string topic, Headers headers, byte[] d
}

/// <summary>
/// Avro Key Json encoder extension of <see cref="KNetSerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// Avro Key Json encoder extension of <see cref="SerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// </summary>
/// <typeparam name="T"></typeparam>
public class Json<T> : KNetSerDes<T>
public class Json<T> : SerDes<T>
{
readonly byte[] keyTypeName = Encoding.UTF8.GetBytes(typeof(T).FullName!);
readonly byte[] keySerDesName = Encoding.UTF8.GetBytes(typeof(Json<>).ToAssemblyQualified());
readonly SpecificDefaultWriter SpecificWriter = new(AvroKeyContainer._SCHEMA);
readonly SpecificDefaultReader SpecificReader = new(AvroKeyContainer._SCHEMA, AvroKeyContainer._SCHEMA);
readonly IKNetSerDes<T> _defaultSerDes = default!;
readonly ISerDes<T> _defaultSerDes = default!;
/// <inheritdoc/>
public override bool UseHeaders => true;
/// <summary>
Expand All @@ -139,20 +139,20 @@ public Json()
{
if (KNetSerialization.IsInternalManaged<T>())
{
_defaultSerDes = new KNetSerDes<T>();
_defaultSerDes = new SerDes<T>();
}
else if (!typeof(T).IsArray)
{
throw new InvalidOperationException($"{typeof(Json<>).ToAssemblyQualified()} cannot manage {typeof(T).Name}, override or build a new serializaer");
}
}

/// <inheritdoc cref="KNetSerDes{T}.Serialize(string, T)"/>
/// <inheritdoc cref="SerDes{T, TJVM}.Serialize(string, T)"/>
public override byte[] Serialize(string topic, T data)
{
return SerializeWithHeaders(topic, null!, data);
}
/// <inheritdoc cref="KNetSerDes{T}.SerializeWithHeaders(string, Headers, T)"/>
/// <inheritdoc cref="SerDes{T, TJVM}.SerializeWithHeaders(string, Headers, T)"/>
public override byte[] SerializeWithHeaders(string topic, Headers headers, T data)
{
headers?.Add(KNetSerialization.KeyTypeIdentifier, keyTypeName);
Expand All @@ -166,12 +166,12 @@ public override byte[] SerializeWithHeaders(string topic, Headers headers, T dat
encoder.Flush();
return memStream.ToArray();
}
/// <inheritdoc cref="KNetSerDes{T}.Deserialize(string, byte[])"/>
/// <inheritdoc cref="SerDes{T, TJVM}.Deserialize(string, byte[])"/>
public override T Deserialize(string topic, byte[] data)
{
return DeserializeWithHeaders(topic, null!, data);
}
/// <inheritdoc cref="KNetSerDes{T}.DeserializeWithHeaders(string, Headers, byte[])"/>
/// <inheritdoc cref="SerDes{T, TJVM}.DeserializeWithHeaders(string, Headers, byte[])"/>
public override T DeserializeWithHeaders(string topic, Headers headers, byte[] data)
{
if (_defaultSerDes != null) return _defaultSerDes.DeserializeWithHeaders(topic, headers, data);
Expand All @@ -186,15 +186,15 @@ public override T DeserializeWithHeaders(string topic, Headers headers, byte[] d
}

/// <summary>
/// Base class to define ValueContainer extensions of <see cref="KNetSerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// Base class to define ValueContainer extensions of <see cref="SerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// </summary>
public static class ValueContainer
{
/// <summary>
/// Avro ValueContainer Binary encoder extension of <see cref="KNetSerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// Avro ValueContainer Binary encoder extension of <see cref="SerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// </summary>
/// <typeparam name="T"></typeparam>
public class Binary<T> : KNetSerDes<T>
public class Binary<T> : SerDes<T>
{
readonly byte[] valueContainerSerDesName = Encoding.UTF8.GetBytes(typeof(Binary<>).ToAssemblyQualified());
readonly byte[] valueContainerName = null!;
Expand Down Expand Up @@ -223,12 +223,12 @@ public Binary()
throw new ArgumentException($"{typeof(T).Name} is not a generic type and cannot be used as a valid ValueContainer type");
}

/// <inheritdoc cref="KNetSerDes{T}.Serialize(string, T)"/>
/// <inheritdoc cref="SerDes{T, TJVM}.Serialize(string, T)"/>
public override byte[] Serialize(string topic, T data)
{
return SerializeWithHeaders(topic, null!, data);
}
/// <inheritdoc cref="KNetSerDes{T}.SerializeWithHeaders(string, Headers, T)"/>
/// <inheritdoc cref="SerDes{T, TJVM}.SerializeWithHeaders(string, Headers, T)"/>
public override byte[] SerializeWithHeaders(string topic, Headers headers, T data)
{
headers?.Add(KNetSerialization.ValueSerializerIdentifier, valueContainerSerDesName);
Expand All @@ -239,12 +239,12 @@ public override byte[] SerializeWithHeaders(string topic, Headers headers, T dat
SpecificWriter.Write(data, encoder);
return memStream.ToArray();
}
/// <inheritdoc cref="KNetSerDes{T}.Deserialize(string, byte[])"/>
/// <inheritdoc cref="SerDes{T, TJVM}.Deserialize(string, byte[])"/>
public override T Deserialize(string topic, byte[] data)
{
return DeserializeWithHeaders(topic, null!, data);
}
/// <inheritdoc cref="KNetSerDes{T}.DeserializeWithHeaders(string, Headers, byte[])"/>
/// <inheritdoc cref="SerDes{T, TJVM}.DeserializeWithHeaders(string, Headers, byte[])"/>
public override T DeserializeWithHeaders(string topic, Headers headers, byte[] data)
{
using MemoryStream memStream = new(data);
Expand All @@ -256,10 +256,10 @@ public override T DeserializeWithHeaders(string topic, Headers headers, byte[] d
}

/// <summary>
/// Avro ValueContainer Json encoder extension of <see cref="KNetSerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// Avro ValueContainer Json encoder extension of <see cref="SerDes{T}"/>, for example <see href="https://masesgroup.github.io/KNet/articles/usageSerDes.html"/>
/// </summary>
/// <typeparam name="T"></typeparam>
public class Json<T> : KNetSerDes<T>
public class Json<T> : SerDes<T>
{
readonly byte[] valueContainerSerDesName = Encoding.UTF8.GetBytes(typeof(Json<>).ToAssemblyQualified());
readonly byte[] valueContainerName = null!;
Expand Down Expand Up @@ -288,12 +288,12 @@ public Json()
throw new ArgumentException($"{typeof(T).Name} is not a generic type and cannot be used as a valid ValueContainer type");
}

/// <inheritdoc cref="KNetSerDes{T}.Serialize(string, T)"/>
/// <inheritdoc cref="SerDes{T, TJVM}.Serialize(string, T)"/>
public override byte[] Serialize(string topic, T data)
{
return SerializeWithHeaders(topic, null!, data);
}
/// <inheritdoc cref="KNetSerDes{T}.SerializeWithHeaders(string, Headers, T)"/>
/// <inheritdoc cref="SerDes{T, TJVM}.SerializeWithHeaders(string, Headers, T)"/>
public override byte[] SerializeWithHeaders(string topic, Headers headers, T data)
{
headers?.Add(KNetSerialization.ValueSerializerIdentifier, valueContainerSerDesName);
Expand All @@ -305,12 +305,12 @@ public override byte[] SerializeWithHeaders(string topic, Headers headers, T dat
encoder.Flush();
return memStream.ToArray();
}
/// <inheritdoc cref="KNetSerDes{T}.Deserialize(string, byte[])"/>
/// <inheritdoc cref="SerDes{T, TJVM}.Deserialize(string, byte[])"/>
public override T Deserialize(string topic, byte[] data)
{
return DeserializeWithHeaders(topic, null!, data);
}
/// <inheritdoc cref="KNetSerDes{T}.DeserializeWithHeaders(string, Headers, byte[])"/>
/// <inheritdoc cref="SerDes{T, TJVM}.DeserializeWithHeaders(string, Headers, byte[])"/>
public override T DeserializeWithHeaders(string topic, Headers headers, byte[] data)
{
using MemoryStream memStream = new(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

<ItemGroup>
<ProjectReference Include="..\KEFCore.SerDes\KEFCore.SerDes.csproj" />
<PackageReference Include="Google.Protobuf" Version="3.25.2" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.25.2">
<PackageReference Include="Google.Protobuf" Version="3.25.3" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.25.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading
Loading