MikValSor.SerializableValidator 1.0.4

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

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.

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
**/

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
**/

Release Notes

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.

  • .NETFramework 4.5

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.4 245 5/22/2018
1.0.3 193 5/22/2018
1.0.2 251 4/30/2018
1.0.1 220 4/30/2018
1.0.0 208 4/30/2018