OVSXmlSerializer 3.0.0-pre2
See the version list below for details.
dotnet add package OVSXmlSerializer --version 3.0.0-pre2
NuGet\Install-Package OVSXmlSerializer -Version 3.0.0-pre2
<PackageReference Include="OVSXmlSerializer" Version="3.0.0-pre2" />
paket add OVSXmlSerializer --version 3.0.0-pre2
#r "nuget: OVSXmlSerializer, 3.0.0-pre2"
// Install OVSXmlSerializer as a Cake Addin #addin nuget:?package=OVSXmlSerializer&version=3.0.0-pre2&prerelease // Install OVSXmlSerializer as a Cake Tool #tool nuget:?package=OVSXmlSerializer&version=3.0.0-pre2&prerelease
Odd's Very Special Xml Serializer
..Or OVSXmlSerializer for short.
The system itself works very similar to how the XML serializer works normally,
but is meant to be worked with the object
or more 'undefined' data that the
ordinary XML serializer have difficulty handling. You can turn this off for
more traditional formatting with the config class, but it does reveal the issue
once again. Additionally, It can handle reference types; allowing multiple
separate fields that contain the same instance; It also allows you to connect a
built-in debugger to specifically track what is wrong with the
serialization/deserialization if needed.
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]
.
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 creating OVSConfig
, 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:
- Always Included - Regardless of the situation, it will write the type.
- Smart Types - When defined out of the base field, it will write the type.
- Ignore - It will never write the type, which may show incorrect behaviour.
Serializing
Like the default system XML serializer, they pose the same requirements such as:
- Requiring to have a public or private parameterless constructor.
- Having all fields follow the same constraint as above.
- During certain restrictions like a limited environment may cause issues; Modifying the readonly handle option in the config seems to fix this.
There are two serializers, the generic and the non-generic. The non-generic derives from the generic as object for performance reasons, and is created as instances due to configurations.
When done serializing as an XML, it typically returns a stream, or applies to a new or existing file.
Note that it does removes the initial xml version and encoding at the top, as it always to be assumed UTF-8 and on version 1.0. This can be changed in the config of course.
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 OVSXmlSerializer
namespace.
Note that System.Xml.Serialization
will be converted automatically if needed.
[XmlIgnore]
Ignores the field completely[XmlAttribute]
Adds primitive value as a single attribute to the class being serialized, can optionally add a name.[XmlNamedAs(string name)]
Changes the field name or object name to something else on XML serialization.[XmlText]
Assuming that all other fields are attributes or ignored, this will write the primitive value[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:
ListInterfaceSerializer
Serializes the list with IList interface, same issue with dictionary serializer.ArraySerializer
Serializes the array as normal, knows what core element it is.DictionarySerializer
Serializes the dictionary using the IDictionary interface, serializing the keys and values with types as the IDictionary doesn't provide generics.DatetimeSerializer
Serializes datetime as normalTimeSpanSerializer
First, and serializes timespan as normal
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
- 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.0 | 73 | 7/10/2024 |
4.0.0-pre2 | 67 | 6/14/2024 |
4.0.0-pre1 | 57 | 6/14/2024 |
3.0.2 | 157 | 9/27/2023 |
3.0.1 | 116 | 9/25/2023 |
3.0.0 | 124 | 9/23/2023 |
3.0.0-pre2 | 92 | 9/21/2023 |
3.0.0-pre1 | 96 | 9/20/2023 |
2.0.4 | 155 | 5/4/2023 |
2.0.3 | 176 | 4/15/2023 |
2.0.2 | 167 | 4/11/2023 |
2.0.1 | 195 | 4/6/2023 |
2.0.0 | 180 | 4/6/2023 |
1.1.5 | 225 | 3/24/2023 |
1.1.4 | 219 | 3/12/2023 |
1.1.3 | 237 | 3/8/2023 |
1.1.2 | 215 | 3/5/2023 |
1.1.1 | 218 | 3/2/2023 |
1.1.0 | 222 | 2/28/2023 |
1.0.2 | 239 | 2/27/2023 |
1.0.1 | 232 | 2/26/2023 |
1.0.1-beta-5 | 130 | 2/25/2023 |
1.0.1-beta-4 | 125 | 2/25/2023 |
1.0.1-beta-3 | 116 | 2/23/2023 |
1.0.1-beta-2 | 132 | 2/21/2023 |
1.0.1-beta | 206 | 2/20/2023 |
1.0.0-beta | 188 | 2/20/2023 |
Its been awhile lol
preview 1:
- Made most classes into a separate 'OVS' prefix to separate them from the system xml serialization more
- Versions feature works a bit differently, i think null values are treated as 1.0 now?
- Things like date-time and lists can have their own external compile config.
- Normal IEnumerables are no longer written/serialized.
- Removed the ignore xml enumerable and instead added a new attribute titled xmlignoreconfigs instead
- Added some OSFile implementation that considers Unix and Windows systems for pathing info as an extra that probably would do better as its own library
preview 2:
- Added missing a single missing method regarding copying contents to a normal stream like a file stream.
- Wrote some additional minor xml documentation.
- Updated the readme a bit
- Changed the namespace from OVSXmlSerializer to OVSSerializer to prevent some weird issues that may have to be fixed by using global::
- Made some errors properly throw some exceptions.