MikValSor.SerializableValidator 1.0.1

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

There is a newer version of this package available.
See the version list below for details.
Install-Package MikValSor.SerializableValidator -Version 1.0.1
dotnet add package MikValSor.SerializableValidator --version 1.0.1
<PackageReference Include="MikValSor.SerializableValidator" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MikValSor.SerializableValidator --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Library for validating that .NET classes 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
**/

Library for validating that .NET classes 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
**/

Release Notes

v1.0.1
- Changed target to not allow null.

v1.0.0
- Initial release.

  • .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 History

Version Downloads Last updated
1.0.4 3,622 5/22/2018
1.0.3 306 5/22/2018
1.0.2 373 4/30/2018
1.0.1 345 4/30/2018
1.0.0 323 4/30/2018