OVSXmlSerializer 4.0.1

dotnet add package OVSXmlSerializer --version 4.0.1
                    
NuGet\Install-Package OVSXmlSerializer -Version 4.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OVSXmlSerializer" Version="4.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OVSXmlSerializer" Version="4.0.1" />
                    
Directory.Packages.props
<PackageReference Include="OVSXmlSerializer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OVSXmlSerializer --version 4.0.1
                    
#r "nuget: OVSXmlSerializer, 4.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OVSXmlSerializer@4.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OVSXmlSerializer&version=4.0.1
                    
Install as a Cake Addin
#tool nuget:?package=OVSXmlSerializer&version=4.0.1
                    
Install as a Cake Tool

Odd's Very Special Xml Serializer

..Or OVSXmlSerializer for short.

The system functions very simply: You put an object inside and it will serialize into a file or such in around 1-2 lines of code. Additionally, is meant to be worked with the object or more 'undefined' data that the ordinary XML serializer have difficulty handling, along with simulating reference types via ID.

Unlike the traditional XML Serializer, this will use the type parameters in the class to automatically differentiate enums and arrays, which will remove the need to mark fields as [XmlArray] or [XmlEnum]. In place, there are custom serializers that you can insert in the config.

These also have the Preprocessors also implemented for versions as well for specific scenarios.

Explicit Types

The unique function of this XML serializer over others is its explicit type handling. What this does is that it allows it to reserve its derived types when considering base types, down to the level of object. This feature can be turned on or off.

This feature is enabled by default, but modifying the serializer/config interface, this can be turned off. It will also implicitly convert System.Xml.XmlWriterSettings to the config to ensure smooth transtion between systems.

There are 3 options you can enable:

  1. Always Included - Regardless of the situation, it will write the type.
  2. Smart Types - When defined out of the base field, it will write the type.
  3. Ignore - It will never write the type, which may show incorrect behaviour.

Serializing

There are two serializers, the generic and the non-generic. The non-generic derives from the generic as object for simplicity, and is typically created as instances due to configurations. Though, there is a shared static parameter for both generic and non-generic serializers.

When done serializing as an XML, it typically returns a stream, or applies to a new or existing file or stream.

It will also recognize that if an object class or a reference type in general is being referenced multiple times in the targeted object to save, then it will try to reference it via the special references you can find on the files. You can disable this behaviour in the config serializers.

Important to note that during certain restrictions like a limited environment may cause issues; Modifying the readonly handle option in the config seems to fix this.

Deserializing

Requires the stream or XML file to retrieve the object mentioned by the XML. It is relatively easy enough, get a file that is generated by the OVSXmlSerializer and it will de-parse it easily, assuming that you know the derived types.

Attributes

Here are a few attributes that uses in its own OVS.XmlSerialization namespace. Note that System.Xml.Serialization will be converted automatically if needed.

  1. [XmlIgnore] Ignores the field completely
  2. [XmlAttribute] Adds primitive value as a single attribute to the class being serialized, can optionally add a name.
  3. [XmlNamedAs(string name)] Changes the field name or object name to something else on XML serialization.
  4. [XmlText] Assuming that all other fields are attributes or ignored, this will write the primitive value
  5. [XmlIgnoreConfigs] Ignores all the customizable serializers when serializing the object or field. Most notably unsafe collections.

Arrays are automatically serialized as its own, and does follow the ignore configs attribute.

Custom Serializers

introduced in 3.0.0

While the serializable interface does work for basic situations, sometimes you need a bit more control, or want to serialize something that is out of your reach (i.e a dll file). One way is to add your own custom serializer that handles on checking what conditions it follows. There is a few already added for Datetime and Timespan. The default serializer list is as follows, and always goes latest added first:

  1. ListInterfaceSerializer Serializes the list with IList interface, same issue with dictionary serializer.
  2. ArraySerializer Serializes the array as normal, knows what core element it is.
  3. DictionarySerializer Serializes the dictionary using the IDictionary interface, serializing the keys and values with types as the IDictionary doesn't provide generics.
  4. LinkedListSerializer Serializes the linked list as a.. list?
  5. DatetimeSerializer Serializes datetime as normal
  6. TimeSpanSerializer First, and serializes timespan as normal
  7. PrimitiveSerializer Starting at the list, serializes objects that can be considered as numbers and such.

OSDirectories

introduced in 3.0.0

Sub-branch of the current serializer, and included as an extra. Simply put, I couldn't find a good library replacement for fileInfo since it doesn't perform well with Unix systems; So i took someone else's (cant remember who) and added some additional functions. Have fun with that i suppose! Uses their own pre-processor definition in case i manage to port it as a standalone library.

Since 4.0.0, this has been moved into its own library: https://www.nuget.org/packages/OVSFileHandler/ Works just fine if you dont have it installed, though.

Product 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1 192 10/26/2024
4.0.0 172 7/10/2024
4.0.0-pre2 153 6/14/2024
4.0.0-pre1 147 6/14/2024
3.0.2 269 9/27/2023
3.0.1 211 9/25/2023
3.0.0 228 9/23/2023
3.0.0-pre2 182 9/21/2023
3.0.0-pre1 206 9/20/2023
2.0.4 295 5/4/2023
2.0.3 314 4/15/2023
2.0.2 312 4/11/2023
2.0.1 344 4/6/2023
2.0.0 321 4/6/2023
1.1.5 375 3/24/2023
1.1.4 363 3/12/2023
1.1.3 378 3/8/2023
1.1.2 357 3/5/2023
1.1.1 356 3/2/2023
1.1.0 369 2/28/2023
Loading failed

- Spend a year after the 4.0 release to fix the list issue, a for loop oversight skipped it.