Git Product home page Git Product logo

objectserialization-net's Introduction

ObjectSerialization-Net

A fast object graph binary serialization for .NET.

Features:

  • support for serialization of classes, structures and primitives at root or type member level;
  • support for serialization of derived types referenced by interface, base class or abstract class type;
  • support for serialization of POCO objects;
  • support for standard NonSerializedAttribute and dedicated NonSerializedBackendAttribute for automatic properties;
  • support for serialization of classes without parameter-less constructor;
  • support for serialization of arrays and collections implementing ICollection<T>;

Download

It is possible to download package using NuGet: PM> Install-Package ObjectSerialization-Net

or compile from sources available on Git: git clone git://github.com/Suremaker/ObjectSerialization-Net.git

Usage:

IObjectSerializer serializer = new ObjectSerializer();

MyClass myObject = new MyClass { Number = 32, Double = 3.14, Text = "test" };

byte[] serializedData = serializer.Serialize(myObject);

MyClass deserialized = serializer.Deserialize<MyClass>(serializedData);

Limitations:

  • if multiple fields refers to the same object instance, after deserialization each would be referring to own copy of it;
  • serialization of object with circular references is not supported (because of above);
  • if class does not contain parameter-less constructor, it would be instantiated without any constructor call;
  • data serialized on .NetFramework may not be properly or accurately deserialized on .NetCore / .Net5 runtime (and vice versa)

Performance and serialized data size:

The ObjectSerializer performs serialization/deserialization faster than standard BinaryFormatter and produces smaller data.

Solution contains ObjectSerialization.Performance project that allows to compare ObjectSerializer performance with other serializers like (BinaryFormatter, DataContractSerializer, Protobuf or Newton BSON).

The last performance comparison can be found here: Performance test results

objectserialization-net's People

Contributors

suremaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

vadim-kor

objectserialization-net's Issues

Build for .Net standart, .NET 5

Hi! Can you please release a build for .NET standard, so the compiler won't show a warning like this:
Package 'ObjectSerialization-Net 1.0.27' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework 'net5.0'. This package may not be fully compatible with your project.

Collection serialization issue

I am getting this exception...

System.Runtime.Serialization.SerializationException: Instance property 'Count' is not defined for type 'System.Collections.Generic.IList1[Microsoft.TeamFoundation.Framework.Server.PropertyValue]&#39; ---&gt; System.ArgumentException: Instance property &#39;Count&#39; is not defined for type &#39;System.Collections.Generic.IList1[Microsoft.TeamFoundation.Framework.Server.PropertyValue]' at System.Linq.Expressions.Expression.Property(Expression expression, String propertyName) at ObjectSerialization.Builders.Types.CollectionTypeSerializer.Write(Expression writerObject, Expression value, Type valueType) in d:\dev\dotnet\ObjectSerialization-Net\ObjectSerialization\Builders\Types\CollectionTypeSerializer.cs:line 47 at ObjectSerialization.Builders.TypeMembersSerializerBuilder1.BuildFieldSerializer(FieldInfo field, BuildContext1 ctx) in d:\dev\dotnet\ObjectSerialization-Net\ObjectSerialization\Builders\TypeMembersSerializerBuilder.cs:line 74 at ObjectSerialization.Builders.TypeMembersSerializerBuilder1.Build() in d:\dev\dotnet\ObjectSerialization-Net\ObjectSerialization\Builders\TypeMembersSerializerBuilder.cs:line 56 --- End of inner exception stack trace --- at ObjectSerialization.Builders.TypeMembersSerializerBuilder1.Build() in d:\dev\dotnet\ObjectSerialization-Net\ObjectSerialization\Builders\TypeMembersSerializerBuilder.cs:line 64 at ObjectSerialization.Builders.TypeMembersSerializerBuilder`1.getSerializeFn() in d:\dev\dotnet\ObjectSerialization-Net\ObjectSerialization\Builders\TypeMembersSerializerBuilder.cs:line 33 at lambdamethod(Closure , BinaryWriter , Object ) at lambdamethod(Closure , BinaryWriter , Object ) at lambdamethod(Closure , BinaryWriter , Object ) at ObjectSerialization.ObjectSerializer.Serialize(Stream stream, Object value) in d:\dev\dotnet\ObjectSerialization-Net\ObjectSerialization\ObjectSerializer.cs:line 29 at ObjectSerialization.ObjectSerializer.Serialize(Object value) in d:\dev\dotnet\ObjectSerialization-Net\ObjectSerialization\ObjectSerializer.cs:line 17

while calling using this code

IObjectSerializer serializer = new ObjectSerializer();
byte[] serializedData = serializer.Serialize(buildEvent);

my buildEvent code is an object of a class which is Sealed and it doesn't have a parameterless constructor.
Please help. Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.