diff --git a/Recyclable.Collections/ThrowHelper.cs b/Recyclable.Collections/ThrowHelper.cs index d19b3b2..9d4f218 100644 --- a/Recyclable.Collections/ThrowHelper.cs +++ b/Recyclable.Collections/ThrowHelper.cs @@ -1,4 +1,6 @@ -namespace Recyclable.Collections +using System.Diagnostics.Contracts; + +namespace Recyclable.Collections { internal static class ThrowHelper { @@ -6,18 +8,30 @@ /// This is a helper method to throw , thrown when the collection was modified during enumeration. /// /// Always - public static void ThrowListModifiedException() => throw new InvalidOperationException("Can't move to the next item, because the collection was modified. You must restart the enumeration by calling Reset(), if you want to enumerate the collection again"); + public static void ThrowListModifiedException() + { + Contract.EnsuresOnThrow(false); + throw new InvalidOperationException("Can't move to the next item, because the collection was modified. You must restart the enumeration by calling Reset(), if you want to enumerate the collection again"); + } /// /// This is a helper method to throw with the given message. /// /// Always - public static void ThrowInvalidOperationException(in string message) => throw new InvalidOperationException(message); + public static void ThrowInvalidOperationException(in string message) + { + Contract.EnsuresOnThrow(false); + throw new InvalidOperationException(message); + } /// /// This is a helper method to throw with the given message. /// /// Always - public static void ThrowArgumentOutOfRangeException(in string argumentName, in string message) => throw new ArgumentOutOfRangeException(argumentName, message); + public static void ThrowArgumentOutOfRangeException(in string argumentName, in string message) + { + Contract.EnsuresOnThrow(false); + throw new ArgumentOutOfRangeException(argumentName, message); + } } }