SerializerHelpers 1.0.5

Suggested Alternatives

System.Text.Json

Additional Details

This project is discontinued. You can use similar serialization logic in System.Text.Json library

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package SerializerHelpers --version 1.0.5
NuGet\Install-Package SerializerHelpers -Version 1.0.5
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="SerializerHelpers" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SerializerHelpers --version 1.0.5
#r "nuget: SerializerHelpers, 1.0.5"
#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.
// Install SerializerHelpers as a Cake Addin
#addin nuget:?package=SerializerHelpers&version=1.0.5

// Install SerializerHelpers as a Cake Tool
#tool nuget:?package=SerializerHelpers&version=1.0.5

Serializer Helpers

Provides helpers for serializer and deserializer of data.

NuGets

Name Info
SerializerHelpers NuGet

Installation

// Install release version
Install-Package SerializerHelpers

// Install pre-release version
Install-Package SerializerHelpers -pre

Supported frameworks

.NET Standard 2.0 and above - see https://github.com/dotnet/standard/blob/master/docs/versions.md for compatibility matrix

Usage

Serializer Sample

using SerializerHelpers;

namespace YourNamespace
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            Dictionary<int, string> dictionary = new();
            dictionary.Add(1, "one");
            dictionary.Add(2, "two");
            dictionary.Add(3, "three");

            // The serialized value of the dictionary
            string? serialized = Serializer.Serialize(test1);
            
            // The vice-versa deserialized value
            Dictionary<int, string>? deserializedDictionary = Serializer.Deserialize<Dictionary<int, string>>(serialized);

            // "dictionary" and "deserializedDictionary" now have the same values.
        }
    }
}

Custom Serializer Implementation Sample

using SerializerHelpers;

namespace YourNamespace
{
    public class Dinosaur
    {
        public string Name { get; set; }
        
        public int Height { get; set; }
    }

    public class DinosaurSerializer : ISerializer<Dinonsaur>
    {
        public string? Serialize(Dinonsaur? value, string? defaultValue = default)
        {
            if (value == null)
            {
                return defaultValue;
            }
            return value.Name + "." + value.Height.ToString();
        }

        public Dinonsaur? Deserialize(string? data, Dinonsaur? defaultValue = default)
        {
            if (data == null)
            {
                return defaultValue;
            }
            string[] values = data.Separate('.');
            return new Dinosaur()
            {
                Name = values[0],
                Height = int.Parse(values[1])
            }
        }
    }
}

Custom Serializer Sample 1

using SerializerHelpers;

namespace YourNamespace
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            // Globally register the serializer.
            Serializer.Register(new DinosaurSerializer());

            Dinosaur dinosaur = new Dinosaur()
            {
                Name = "T-Rex",
                Height = 100
            }

            // The serialized value of the dinosaur
            string? serialized = Serializer.Serialize(dinosaur);
            
            // The vice-versa deserialized value
            Dinosaur? deserializedDinosaur = Serializer.Deserialize<Dinosaur>(serialized);

            // "dinosaur" and "deserializedDinosaur" now have the same values.
        }
    }
}

Custom Serializer Sample 2

using SerializerHelpers;

namespace YourNamespace
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            // Globally register the serializer.
            Serializer.Register(new DinosaurSerializer());

            Dictionary<int, Dinosaur> dinosaurs = new();
            dinosaurs.Add(1, new Dinosaur()
            {
                Name = "T-Rex",
                Height = 100
            });
            dinosaurs.Add(2, new Dinosaur()
            {
                Name = "Titanosauria",
                Height = 200
            });

            // The serialized value of the dinosaurs
            string? serialized = Serializer.Serialize(test1);
            
            // The vice-versa deserialized value
            Dictionary<int, Dinosaur>? deserializedDinosaurs = Serializer.Deserialize<Dictionary<int, Dinosaur>>(serialized);

            // "dinosaurs" and "deserializedDinosaurs" now have the same values.
        }
    }
}

Want To Support This Project?

All I have ever asked is to be active by submitting bugs, features, and sending those pull requests down!.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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. 
.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 is compatible. 
.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.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.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

* Fixed dictionary decode exception on empty items.