Skip to content

Add complex type management with a new specialized IComplexTypeConverterFactory - #446

Merged
masesdevelopers merged 17 commits into
masterfrom
445-manage-complextype-both-into-the-engine-and-in-serializers
Feb 27, 2026
Merged

masesdevelopers merged 17 commits into
masterfrom
445-manage-complextype-both-into-the-engine-and-in-serializers

Conversation

@masesdevelopers

@masesdevelopers masesdevelopers commented Feb 26, 2026 •

Copy link
Copy Markdown
Collaborator

Description

  • Add complex type and bytes support to SerDes
    Introduce support for complex/strong-typed properties and raw byte[] values across Avro and Protobuf serialization. Changes include: updated Avro schemas and generated classes to include "bytes" for property values; extended AvroValueContainer to accept complexProperties, complexPropertyValues and an IComplexTypeConverterFactory, with a BuildPropertyValue helper and ConvertBack handling. Protobuf: extended GenericValue.proto with ComplexType message and bytes/complextype variants, updated generated Protobuf classes and added ComplexType constructors/GetContent conversion helpers that use IComplexTypeConverterFactory. New interfaces and factory (IComplexTypeConverter, IComplexTypeConverterFactory, ComplexTypeConverterFactory) were added and related SerDes and helper types updated (IValueContainer, DefaultValueContainer, KEFCore SerDes helpers, etc.). Also updated several storage/Kafka-related internal classes to accommodate the new value handling. These changes enable converting complex CLR types to storable representations and back when reading data.

  • Add PreferredConversionType and update converters
    Introduce PreferredConversionType (Text/Binary) to indicate serializer preference and update IComplexTypeConverter signatures to accept it. Adjusted all call sites and implementations to pass Text or Binary as appropriate (Avro/Protobuf use Binary; DefaultValueContainer uses Text). Made Properties nullable in DefaultValueContainer and fixed conversion direction calls (Convert vs ConvertBack). Updated example converter and docs (split char, exception logging) and removed an unused using in Protobuf file.

Related Issue

closed #445

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Introduce support for complex/strong-typed properties and raw byte[] values across Avro and Protobuf serialization. Changes include: updated Avro schemas and generated classes to include "bytes" for property values; extended AvroValueContainer to accept complexProperties, complexPropertyValues and an IComplexTypeConverterFactory, with a BuildPropertyValue helper and ConvertBack handling. Protobuf: extended GenericValue.proto with ComplexType message and bytes/complextype variants, updated generated Protobuf classes and added ComplexType constructors/GetContent conversion helpers that use IComplexTypeConverterFactory. New interfaces and factory (IComplexTypeConverter, IComplexTypeConverterFactory, ComplexTypeConverterFactory) were added and related SerDes and helper types updated (IValueContainer, DefaultValueContainer, KEFCore SerDes helpers, etc.). Also updated several storage/Kafka-related internal classes to accommodate the new value handling. These changes enable converting complex CLR types to storable representations and back when reading data.
@masesdevelopers masesdevelopers self-assigned this Feb 26, 2026
@masesdevelopers masesdevelopers added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 26, 2026
@masesdevelopers masesdevelopers linked an issue Feb 26, 2026 that may be closed by this pull request
@masesdevelopers masesdevelopers added KEFCore The issue is releated to KEFCore KEFCore SerDes The issue is releated to KEFCore SerDes labels Feb 26, 2026
Comment thread test/KEFCore.Complex.Test/Program.cs Fixed
Comment thread test/KEFCore.Complex.Test/Program.cs Fixed
Comment thread src/net/KEFCore.SerDes/DefaultValueContainer.cs Fixed
Comment thread test/KEFCore.Complex.Test/Program.cs Fixed
Comment thread src/net/KEFCore.SerDes/ComplexTypeConverterFactory.cs Fixed
Comment thread src/net/KEFCore.SerDes/ComplexTypeConverterFactory.cs Fixed
Comment thread src/net/KEFCore.SerDes/DefaultValueContainer.cs Fixed
Comment thread src/net/KEFCore.SerDes.Avro/AvroValueContainer.cs Fixed
Comment thread src/net/KEFCore.SerDes.Protobuf/Storage/ProtobufValueContainer.cs Fixed
masesdevelopers and others added 3 commits February 26, 2026 04:00
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Comment thread test/KEFCore.Complex.Test/Program.cs Fixed
Comment thread test/KEFCore.Complex.Test/Program.cs Fixed
Comment thread src/net/KEFCore.SerDes.Protobuf/Storage/ProtobufValueContainer.cs Fixed
Comment thread test/KEFCore.Complex.Test/Program.cs Fixed
Comment thread test/Common/Model.cs Fixed
Comment thread test/Common/Model.cs Fixed
Comment thread test/KEFCore.Complex.Test/Program.cs Fixed
Comment thread test/KEFCore.Complex.Test/Program.cs Fixed
Comment thread test/Common/Model.cs Dismissed
Introduce PreferredConversionType (Text/Binary) to indicate serializer preference and update IComplexTypeConverter signatures to accept it. Adjusted all call sites and implementations to pass Text or Binary as appropriate (Avro/Protobuf use Binary; DefaultValueContainer uses Text). Made Properties nullable in DefaultValueContainer and fixed conversion direction calls (Convert vs ConvertBack). Updated example converter and docs (split char, exception logging) and removed an unused using in Protobuf file.
Comment thread src/net/KEFCore.SerDes/DefaultValueContainer.cs Fixed
Comment thread src/net/KEFCore.SerDes.Protobuf/Storage/ProtobufValueContainer.cs Fixed
Comment thread test/KEFCore.Complex.Test/Program.cs Dismissed
Comment thread test/KEFCore.Complex.Test/Program.cs Dismissed
Comment thread test/KEFCore.Complex.Test/Program.cs Dismissed
@masesdevelopers

Copy link
Copy Markdown
Collaborator Author

Some tests fail for this reasons:

The PR can be merged

@masesdevelopers
masesdevelopers merged commit 8d44a47 into master Feb 27, 2026
353 of 413 checks passed
@masesdevelopers
masesdevelopers deleted the 445-manage-complextype-both-into-the-engine-and-in-serializers branch February 27, 2026 00:50
masesdevelopers added a commit to masesgroup/KNet that referenced this pull request Feb 28, 2026
Applies the fix of masesgroup/KEFCore#446 to avoid errors when executing some tests
masesdevelopers added a commit to masesgroup/KNet that referenced this pull request Feb 28, 2026
* Make RecordMetadata.DateTime nullable

Return a nullable DateTime for RecordMetadata.DateTime and guard conversion with HasTimestamp(). This avoids producing a DateTime for records without a timestamp (returns null instead). Also updated the XML doc comment to reflect the nullable return and changed the conversion logic to only call Timestamp() when HasTimestamp() is true.

* Apply the fix for test execution on GitHub

Applies the fix of masesgroup/KEFCore#446 to avoid errors when executing some tests
masesdevelopers added a commit to masesgroup/KNet that referenced this pull request Feb 28, 2026
* Make RecordMetadata.DateTime nullable

Return a nullable DateTime for RecordMetadata.DateTime and guard conversion with HasTimestamp(). This avoids producing a DateTime for records without a timestamp (returns null instead). Also updated the XML doc comment to reflect the nullable return and changed the conversion logic to only call Timestamp() when HasTimestamp() is true.

* Apply the fix for test execution on GitHub

Applies the fix of masesgroup/KEFCore#446 to avoid errors when executing some tests
masesdevelopers added a commit to masesgroup/KNet that referenced this pull request Feb 28, 2026
* Make RecordMetadata.DateTime nullable

Return a nullable DateTime for RecordMetadata.DateTime and guard conversion with HasTimestamp(). This avoids producing a DateTime for records without a timestamp (returns null instead). Also updated the XML doc comment to reflect the nullable return and changed the conversion logic to only call Timestamp() when HasTimestamp() is true.

* Apply the fix for test execution on GitHub

Applies the fix of masesgroup/KEFCore#446 to avoid errors when executing some tests

@masesdevelopers masesdevelopers left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update Avro and Protobuf serializers

{
foreach (var item in complexProperties)
{
int index = item.GetIndex();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use GetIndex because complexPropertyValues are stored based on the same index of complexProperties. See DefaultValueContainer of Json

{
foreach (var item in complexProperties)
{
int index = item.GetIndex();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -53,41 +57,78 @@ public AvroValueContainer(IEntityType tName, IProperty[]? properties, object[] r
{
int index = item.GetIndex();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same of https://github.com/masesgroup/KEFCore/pull/446/changes#r2873168382 is valid for properties and propertyValues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request KEFCore SerDes The issue is releated to KEFCore SerDes KEFCore The issue is releated to KEFCore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manage ComplexType both into the engine and in serializers

1 participant