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

✨ Refactor and improvements in binary object (de)serialization #208

Merged
merged 10 commits into from
Jan 30, 2024

Conversation

pleonex
Copy link
Member

@pleonex pleonex commented Jan 30, 2024

Move the binary (de)serialization of objects (class / struct) into new types and improvements.

  • πŸ‘• Refactor serialization code into new types: BinarySerializer and BinaryDeserializer
    • DataWriter and DataReader only deal with primitive types, arrays and strings
  • πŸ› Fix undefined property order by introducing the new attribute BinaryOrder
    • Mandatory in .NET 6, optional in .NET 8
  • ✨ Serializer type inspection customizable via new interface ITypeFieldsNavigator. Default implementation inspects the public properties with getter and setter
  • πŸ‘• Rename attribute BinaryForceEndianness to BinaryEndianness
  • πŸ‘• Move attribute properties WriteAs and ReadAs into UnderlyingType
  • ✨ The default type for enums is now its underlying defined type in code
  • ✨ Support properties from base classes (inheritance)
  • ✨ New API in DataWriter to write integers of 24-bits
  • πŸ”₯ The attribute BinarySerializable is not used anymore
  • β˜” Add more unit tests
  • ⬆️ Minor unrelated changes: update dependencies and build system

This PR closes #207

Quality check list

  • Related code has been tested automatically or manually
  • Related documentation is updated It doesn't exist yet
  • I acknowledge I have read and filled this checklist and accept the
    developer certificate of origin

Acceptance criteria

  • Code related to binary (de)serialization is in a separate class
  • Issue in property order is fixed

Follow-up work

  • Documentation

Example

SimpleType obj = BinaryDeserializer.Deserialize<SimpleType>(stream);

BinarySerializer.Serialize(stream, obj);

@pleonex pleonex added this to the v4.0 milestone Jan 30, 2024
@pleonex pleonex self-assigned this Jan 30, 2024
@pleonex pleonex linked an issue Jan 30, 2024 that may be closed by this pull request
10 tasks
@pleonex pleonex merged commit bffa8c5 into develop Jan 30, 2024
5 checks passed
@pleonex pleonex deleted the feature/split-binaryserializer branch January 30, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API enhancements for reflection-based object binary serialization and deserialization
1 participant