YellowMan.Data 2.0.1

dotnet add package YellowMan.Data --version 2.0.1
                    
NuGet\Install-Package YellowMan.Data -Version 2.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="YellowMan.Data" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YellowMan.Data" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="YellowMan.Data" />
                    
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 YellowMan.Data --version 2.0.1
                    
#r "nuget: YellowMan.Data, 2.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 YellowMan.Data@2.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=YellowMan.Data&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=YellowMan.Data&version=2.0.1
                    
Install as a Cake Tool

SINCE VERSION 2.0.0, THE SYNTAX HAS COMPLETELY CHANGED, SO THE PREVIOUS VERSIONS ARE NO LONGER RELEVANT!

Greetings from YellowMan! I created this serializer as a specific solution for those who, for some reason, are not suitable for others. My code is not a reference, so I ask you not to be surprised by what you have written. I would be glad to have your feedback 😃

News

  • Additional edits have been introduced.
  • Temporarily added the method: "Serializer.Deserialize(path, itemName, ref object)".

Serialize

We have a data class.

class Data
{
    public int Int = 1;
    public float Float = 1.01F;
    public double Double = 1.0001D;
    public decimal Decimal = 1.00000001M;
    public char Char = 'C';
    public string String = "String";
    public bool Bool = true;
    public (int, string) Tuple = (1, "String");
    public int[] Array = new int[] { 1, 2};
    public int[,,,] MultiArray = new int[1, 1, 1, 1];
    public List<int> List = new List<int>() { 1, 2 };
    public Dictionary<int, string> Dictionary = new Dictionary<int, string>() { { 1, "StringOne" }, { 2, "StringTwo" } };
    public Vector2 Vector2 = new Vector2(1, 1);
    public DateTime DateTime = new DateTime(2000, 1, 1);
    public string Null = null;
}

This is what the serialization process looks like:

Data data = new Data();

string json = Serializer.Serialize("data", "Data", data);

// The file "data.json"
//
// Data
// {
//   "System.Int32.Int": 1,
//   "System.Single.Float": 1.01F,
//   "System.Double.Double": 1.0001D,
//   "System.Decimal.Decimal": 1.00000001M,
//   "System.Char.Char": 'C',
//   "System.String.String": "String",
//   "System.Boolean.Bool": True,
//   "System.ValueTuple`2[System.Int32,System.String].Tuple": [
//      "System.Int32.Item1": 1,
//      "System.String.Item2": "String"
//   ],
//   "System.Int32[].Array": [
//      "System.Int32.Item1": 1,
//      "System.Int32.Item2": 2
//   ],
//   "System.Int32[,,,].MultiArray": [
//      "System.Int32.Item1": [
//         "System.Int32.Item1": [
//            "System.Int32.Item1": [
//               "System.Int32.Item1": 0
//            ]
//         ]
//      ]
//   ],
//   "System.Collections.Generic.List`1[System.Int32].List": [
//      "System.Int32.Item1": 1,
//      "System.Int32.Item2": 2
//   ],
//   "System.Collections.Generic.Dictionary`2[System.Int32,System.String].Dictionary": [
//      "System.Int32.Keys": [
//         "System.Int32.Key1": 1,
//         "System.Int32.Key2": 2
//      ],
//      "System.String.Values": [
//         "System.String.Value1": "StringOne",
//         "System.String.Value2": "StringTwo"
//      ]
//   ],
//   "System.Numerics.Vector2.Vector2": {
//      "System.Single.X": 1F,
//      "System.Single.Y": 1F
//   },
//   "System.DateTime.DateTime": "01.01.2000 0:00:00",
//   "System.String.Null": null
// }

The standard format: "Serializer.Serialize(path, itemName, item)". But there is also this: "Serializer.Serialize(path, itemName, item, mode)". By default, the mode is enabled during serialization: "SerializationMode.NotUseAttribute". But for additional correction, you can use the attributes: "[Save]" and "[Skip]", and their modes. Next is a small table with an example of using the mode and attribute.

In a serializable class:

NotUseAttribute UseAttribute Hybrid DeepUseAttribute DeepHybrid
private ☓ ☓ ☓ ☓ ☓
public ✓ ☓ ✓ ☓ ✓
[Save] private ☓ ✓ ✓ ✓ ✓
[Save] public ✓ ✓ ✓ ✓ ✓
[Skip] private/public ☓ ☓ ☓ ☓ ☓
[Skip] [Save] private/public ☓ ☓ ☓ ☓ ☓

In an instance of the class:

NotUseAttribute UseAttribute Hybrid DeepUseAttribute DeepHybrid
private ☓ ☓ ☓ ☓ ☓
public ✓ ✓ ✓ ☓ ✓
[Save] private ☓ ☓ ☓ ✓ ✓
[Save] public ✓ ✓ ✓ ✓ ✓
[Skip] private/public ☓ ☓ ☓ ☓ ☓
[Skip] [Save] private/public ☓ ☓ ☓ ☓ ☓

Deserialize

Data data = Serializer.Deserialize<Data>("data", "Data");

Or

Data data = new Data();
object dataObject = data; 
Serializer.Deserialize("data", "Data", ref dataObject);

Sterilize anything (almost)! P.S. I hope there are no bugs :p

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.

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
2.0.1 362 6/11/2025
2.0.0 209 6/5/2025