Presentation of UniversalSerializer
UniversalSerializer is a free open-source advanced serializer for .NET and .NET Core.
It has been designed to be able to serialize very complex types with ease (as the WPF's Window class for example).
It can run on Windows, Linux, Android and (probably) macOS1 and iOS1.
Get the compiled libraries
Three NuGet packages are available that contain the compiled DLLs:- UniversalSerializer
The main package, containing the 8 main libraries. - UniversalSerializer.WPF
The specific library for the WPF types.
This package depends on the main package. - UniversalSerializer.Windows.Forms
The specific library for the Windows Forms types.
For versionning reasons, it includes the right main UniversalSerializer library. Therfore this package does not depend on the main package.
Some characteristics
- No need to add attributes nor interfaces to the types (classes & structures).
- Optional mechanisms let you serialize types that would not serialize normally:
encapsulation in Containers, Filters, and additionnal attributes. - A class instance can be referenced multiple times (it is not duplicated).
- Circular references are allowed.
- Existing serialization or transcoding mechanisms are reused.
Currently:[Serializable]
,ISerializable
,[ValueSerializer]
, and[TypeConverter]
. - Types with no default constructor are allowed, if a parametric constructor can be found (it is automatic).
- Not-generic
ICollection
classes can be serialized if an Add or an Insert method can be found (private or public functions are found automatically). - I added specialized libraries that let you serialize types of WPF and Windows Forms.
Sources
The sources are available on GitHub.
Technical article
You can read the article I wrote on CodeProject.
It presents UniversalSerializer in details, and explains its origin and some of the techniques I introduced for it.
The DLLs
The available libraries are:
Library platform | Operating systems | File formats | ||||||
Windows | macOS1 | Linux | Android | iOS1 | Binary | XML | json | |
.NET 3.5 | yes | no | no | no | no | yes | yes | no |
.NET 4.0 | yes | Mono | Mono | Xamarin | Xamarin | yes | yes | yes |
.NET 4.5 | yes | Mono | Mono | Xamarin | Xamarin | yes | yes | yes |
.NET Core 2 | yes | yes | yes | no | no | yes | yes | yes |
.NET Standard 2 | yes | yes | yes | Xamarin | Xamarin | yes | yes | yes |
Android | Xamarin | yes | yes | yes | ||||
Silverlight | yes | yes | no | no | no | yes | yes | yes |
UWP (Universal Windows) | yes | no | no | no | no | yes | yes | no |
Windows Forms on .NET 3.5 | yes | no | no | no | no | yes | yes | yes |
Windows Forms on .NET 4.0 | yes | no | no | no | no | yes | yes | yes |
WPF | yes | no | no | no | no | yes | yes | yes |
And a test application under Xamarin Forms (using the .NET Standard library), on Windows, Android and iOS.
A code example
var data = new Hashtable(); data.Add(0, 1); using (var s = new UniversalSerializer("serialized.uniser")) { s.Serialize(data); var data2 = s.Deserialize<Hashtable>(); }
There are more examples on this page.
(1) Apple: Some libraries are compiled for macOS and iOS. But I did not test them on these systems (I don't own this hardware).