<commit_before>NGuard
=========

Introduction
------------
Lightweight guard / pre-condition / parameter validation framework for .NET

Using a guard
-------------
````csharp
// Simple example:
void ExampleMethod(string input)
{
    Guard.Requires(input, "input").IsNotNull();
    
    // method body
}

// Chaining guards:
void ExampleMethod(string input)
{
    Guard.Requires(input, "input").IsNotNull().IsNotEmpty().IsNotWhiteSpace();
    
    // method body
}
````

Defining a custom guard
-----------------------
````csharp
// Example guard definition:
static Guard<CustomType> SatisfiesCustomCondition(this Guard<CustomType> guard)
{
    if (guard.Value != null)
    {
        bool valid = /* code to test custom condition */
        if (!valid)
        {
            string paramName = guard.ParameterName;
            string message = paramName + " should satisfy custom condition.";
            throw new ArgumentException(message, paramName);
        }
    }
	
	return guard;
}

// Example guard usage:
void ExampleMethod(CustomType value)
{
    Guard.Requires(value, "value").SatisfiesCustomCondition();
    
    // method body
}
````

Copyright
---------
Copyright <NAME> 2012-2016.

License
-------
NGuard is licensed under the [MIT License](https://opensource.org/licenses/MIT). Refer to license.txt for more information.<commit_msg>Use modern language features in the examples.<commit_after>NGuard
=========

Introduction
------------
Lightweight guard / pre-condition / parameter validation library for .NET

Using a guard
-------------
````csharp
// Simple example:
void ExampleMethod(string input)
{
    Guard.Requires(input, nameof(input)).IsNotNull();
    
    // method body
}

// Chaining guards:
void ExampleMethod(string input)
{
    Guard.Requires(input, nameof(input)).IsNotNull().IsNotEmpty().IsNotWhiteSpace();
    
    // method body
}
````

Defining a custom guard
-----------------------
````csharp
// Example guard definition:
static Guard<CustomType> SatisfiesCustomCondition(this Guard<CustomType> guard)
{
    if (guard.Value != null)
    {
        bool valid = /* code to test custom condition */
        if (!valid)
        {
            string paramName = guard.ParameterName;
            string message = $"{paramName} should satisfy custom condition.";
            throw new ArgumentException(message, paramName);
        }
    }
	
	return guard;
}

// Example guard usage:
void ExampleMethod(CustomType value)
{
    Guard.Requires(value, nameof(value)).SatisfiesCustomCondition();
    
    // method body
}
````

Copyright
---------
Copyright <NAME> 2012-2016.

License
-------
NGuard is licensed under the [MIT License](https://opensource.org/licenses/MIT). Refer to license.txt for more information.
{'fraction_non_alphanumeric': 0.1601021152443472, 'fraction_numerical': 0.005835156819839533, 'mean_word_length': 2.6671122994652405, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6973470', 'n_tokens_mistral': 760, 'n_tokens_neox': 729, 'n_words': 207}