Skip to content

mikkelvalentinsorensen/MikValSor.ImmutableValidator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library for validating that .NET types are immutable.

Nuget package: https://www.nuget.org/packages/MikValSor.ImmutableValidator

Example:

class MyClass
{
	public string Value;
}

class MyOtherClass
{
	public readonly string Value;
	public MyOtherClass(string value)
	{
		Value = value;
	}
}

void Validate()
{
	var validator = new MikValSor.Immutable.ImmutableValidator();

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

	var myOtherObject = new MyOtherClass("Value");
	bool isMyOtherObjectImmutable = validator.IsImmutable(myOtherObject);
	System.Console.WriteLine($"Is myOtherObject immutable: {isMyOtherObjectImmutable}");
}
/**
	Output:
	Is myObject immutable: False
	Is myOtherObject immutable: True
**/

About

Library for validating that .NET classes are immutable.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages