Eocron.Serialization
1.1.0
See the version list below for details.
dotnet add package Eocron.Serialization --version 1.1.0
NuGet\Install-Package Eocron.Serialization -Version 1.1.0
<PackageReference Include="Eocron.Serialization" Version="1.1.0" />
paket add Eocron.Serialization --version 1.1.0
#r "nuget: Eocron.Serialization, 1.1.0"
// Install Eocron.Serialization as a Cake Addin #addin nuget:?package=Eocron.Serialization&version=1.1.0 // Install Eocron.Serialization as a Cake Tool #tool nuget:?package=Eocron.Serialization&version=1.1.0
Eocron.Serialization
This library is inteded to unify C# wide known frameworks for serialization under one interface. The list include:
XmlDocument
/XDocument
serialization usingXmlSerializer
/XmlObjectSerializer
- Yaml serialization
- Json serialization
- Protobuf serialization
Common interface they share is ISerializationConverter
and all string
/byte
/stream
extensions are based on this interface.
Main path of defining converter is to make it as singleton and use everywhere, so its best to avoid creating those per-call (in most cases it should not affect performance).
Example:
public static readonly ISerializationConverter XDocument =
new XmlSerializationConverter<XDocument>(
new XmlAdapter<XDocument>(
new XmlSerializerAdapter(x => new XmlSerializer(x)),
new XDocumentAdapter()));
Or:
public static readonly ISerializationConverter XmlDataContract =
new XmlSerializationConverter<XmlDocument>(
new XmlAdapter<XmlDocument>(
new XmlObjectSerializerAdapter(x => new DataContractSerializer(x)),
new XmlDocumentAdapter()));
Or:
public static readonly ISerializationConverter Json = new JsonSerializationConverter(
new JsonSerializerSettings()
{
Formatting = Formatting.Indented
});
Usage:
var xml = XmlDataContract.SerializeToString(myObj);
XmlDataContract.SerializeTo(myObj, stream);
var bytes = XmlDataContract.SerializeToBytes(myObj);
XML
Because of many problems related to XML in C# such as:
- Multiple versions of documents like
XmlDocument
,XDocument
- Multiple versions of serializers like
XmlSerializer
,XmlObjectSerializer
,DataContractSerializer
which work with both types of documents - Various markups like
XmlRoot
/DataContract
/ISerializable
- Constant problems of serializing basic types like
Dictionary
/TimeSpan
which in one version throw error, in other it will just silently empty your fields (Say HI! toTimeSpan
being empty in .net472). - Chaotic changes from Microsoft to blow up your tests (rearrangment of namespaces, adding encoding attribute, etc) and sometimes criple back-compatability (Say HI! to BOM in .net6)
I decided to unify all this architectural garbage into couple of adapters, so it is easier to configure entire serialization process, such as initial settings on namespaces/readers/writers/serializers and XSLT transformations on document, so you choose your own pill to swallow. This should give 100% percent coverage on schema formats and compatability with bugs-as-feature, but can sometimes lower performance tweak flexibility. But who cares? XML is slow/old and you know it. Use Json where it is possible.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 9.0.1)
- protobuf-net (>= 3.1.22)
- YamlDotNet (>= 12.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.