MikValSor.SerializableValidator 1.0.4

Install-Package MikValSor.SerializableValidator -Version 1.0.4
dotnet add package MikValSor.SerializableValidator --version 1.0.4
<PackageReference Include="MikValSor.SerializableValidator" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MikValSor.SerializableValidator --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MikValSor.SerializableValidator, 1.0.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MikValSor.SerializableValidator as a Cake Addin
#addin nuget:?package=MikValSor.SerializableValidator&version=1.0.4

// Install MikValSor.SerializableValidator as a Cake Tool
#tool nuget:?package=MikValSor.SerializableValidator&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Library for validating that .NET types are serializable and deserialize with System.Runtime.Serialization.

Example:

class MyClass
{
	public string Value;
}

[System.Serializable]
class MyOtherClass : System.Runtime.Serialization.ISerializable
{
	public string Value;

	public MyOtherClass()
	{
	}

	private MyOtherClass(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
	{
		Value = (string)info.GetValue("Value", typeof(string));
	}

	void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
	{
		info.AddValue("Value", Value, typeof(string));
	}
}

void Validate()
{
	var validator = new MikValSor.Runtime.Serialization.SerializableValidator();

	var myObject = new MyClass();
	bool isMyObjectImmutable = validator.IsSerializable(myObject);
	System.Console.WriteLine($"Is myObject serializable: {isMyObjectImmutable}");

	var myOtherObject = new MyOtherClass();
	bool isMyOtherObjectImmutable = validator.IsSerializable(myOtherObject);
	System.Console.WriteLine($"Is myOtherObject serializable: {isMyOtherObjectImmutable}");
}
/**
	Output:
	Is myObject serializable: False
	Is myOtherObject serializable: True
**/
  • .NETFramework 4.5

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on MikValSor.SerializableValidator:

Package Downloads
MikValSor.EnsuredImmutable

Package Description

MikValSor.ImmutableStore

Library for storage of immutable .Net types.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 4,039 5/22/2018
1.0.3 555 5/22/2018
1.0.2 664 4/30/2018
1.0.1 632 4/30/2018
1.0.0 621 4/30/2018

v1.0.4
- Added NullIsNotSerializable instead for ArgumentNullException
- Changes names of Exceptions to have Exception in end of name.

v1.0.3
- Added singelton instance

v1.0.2
- Added support for structs

v1.0.1
- Changed target to not allow null.

v1.0.0
- Initial release.