Kalkwst / MicroLib

MIT License
3 stars 0 forks source link

🩹 Change error throwing to use the new built in methods. #51

Closed kgrontis closed 1 year ago

kgrontis commented 1 year ago

We should change the exception throwing to the new built in methods provided by Microsoft. https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception.throwifnullorempty?view=net-7.0 https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception.throwifnull?view=net-7.0#system-argumentnullexception-throwifnull(system-object-system-string)

The ArgumentException.ThrowIfNullOrEmpty was introduced in .NET 7 & ArgumentNullException.ThrowIfNull on .NET 6.

Example: from

    protected AbstractCollectionDecorator(ICollection<T> collection)
    {
        _collection = collection ?? throw new ArgumentNullException(nameof(collection));
    }

to

    protected AbstractCollectionDecorator(ICollection<T> collection)
    {
        ArgumentNullException.ThrowIfNull(collection);
        _collection = collection;
    }