Added FisheryLib.Collections.FishTable and Mono.Cecil extension methods

A bit of refactoring has been done too
This commit is contained in:
bbradson
2023-06-03 20:10:58 +02:00
parent 8fa92f15a6
commit cdf209eb02
72 changed files with 8145 additions and 2098 deletions
@@ -30,7 +30,8 @@ public static partial class ThrowHelper
/// <exception cref="ArrayTypeMismatchException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowArrayTypeMismatchException<T>(string? message) => throw new ArrayTypeMismatchException(message);
public static T ThrowArrayTypeMismatchException<T>(string? message)
=> throw new ArrayTypeMismatchException(message);
/// <summary>
/// Throws a new <see cref="ArrayTypeMismatchException"/>.
@@ -41,7 +42,8 @@ public static partial class ThrowHelper
/// <exception cref="ArrayTypeMismatchException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowArrayTypeMismatchException<T>(string? message, Exception? innerException) => throw new ArrayTypeMismatchException(message, innerException);
public static T ThrowArrayTypeMismatchException<T>(string? message, Exception? innerException)
=> throw new ArrayTypeMismatchException(message, innerException);
/// <summary>
/// Throws a new <see cref="ArgumentException"/>.
@@ -71,7 +73,8 @@ public static partial class ThrowHelper
/// <exception cref="ArgumentException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowArgumentException<T>(string? message, Exception? innerException) => throw new ArgumentException(message, innerException);
public static T ThrowArgumentException<T>(string? message, Exception? innerException)
=> throw new ArgumentException(message, innerException);
/// <summary>
/// Throws a new <see cref="ArgumentException"/>.
@@ -82,7 +85,8 @@ public static partial class ThrowHelper
/// <exception cref="ArgumentException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowArgumentException<T>(string? name, string? message) => throw new ArgumentException(message, name);
public static T ThrowArgumentException<T>(string? name, string? message)
=> throw new ArgumentException(message, name);
/// <summary>
/// Throws a new <see cref="ArgumentException"/>.
@@ -94,7 +98,8 @@ public static partial class ThrowHelper
/// <exception cref="ArgumentException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowArgumentException<T>(string? name, string? message, Exception? innerException) => throw new ArgumentException(message, name, innerException);
public static T ThrowArgumentException<T>(string? name, string? message, Exception? innerException)
=> throw new ArgumentException(message, name, innerException);
/// <summary>
/// Throws a new <see cref="ArgumentNullException"/>.
@@ -124,7 +129,8 @@ public static partial class ThrowHelper
/// <exception cref="ArgumentNullException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowArgumentNullException<T>(string? name, Exception? innerException) => throw new ArgumentNullException(name, innerException);
public static T ThrowArgumentNullException<T>(string? name, Exception? innerException)
=> throw new ArgumentNullException(name, innerException);
/// <summary>
/// Throws a new <see cref="ArgumentNullException"/>.
@@ -135,7 +141,8 @@ public static partial class ThrowHelper
/// <exception cref="ArgumentNullException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowArgumentNullException<T>(string? name, string? message) => throw new ArgumentNullException(name, message);
public static T ThrowArgumentNullException<T>(string? name, string? message)
=> throw new ArgumentNullException(name, message);
/// <summary>
/// Throws a new <see cref="ArgumentOutOfRangeException"/>.
@@ -165,7 +172,8 @@ public static partial class ThrowHelper
/// <exception cref="ArgumentOutOfRangeException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowArgumentOutOfRangeException<T>(string? name, Exception? innerException) => throw new ArgumentOutOfRangeException(name, innerException);
public static T ThrowArgumentOutOfRangeException<T>(string? name, Exception? innerException)
=> throw new ArgumentOutOfRangeException(name, innerException);
/// <summary>
/// Throws a new <see cref="ArgumentOutOfRangeException"/>.
@@ -176,7 +184,8 @@ public static partial class ThrowHelper
/// <exception cref="ArgumentOutOfRangeException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowArgumentOutOfRangeException<T>(string? name, string? message) => throw new ArgumentOutOfRangeException(name, message);
public static T ThrowArgumentOutOfRangeException<T>(string? name, string? message)
=> throw new ArgumentOutOfRangeException(name, message);
/// <summary>
/// Throws a new <see cref="ArgumentOutOfRangeException"/>.
@@ -188,7 +197,8 @@ public static partial class ThrowHelper
/// <exception cref="ArgumentOutOfRangeException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowArgumentOutOfRangeException<T>(string? name, object? value, string? message) => throw new ArgumentOutOfRangeException(name, value, message);
public static T ThrowArgumentOutOfRangeException<T>(string? name, object? value, string? message)
=> throw new ArgumentOutOfRangeException(name, value, message);
/// <summary>
/// Throws a new <see cref="COMException"/>.
@@ -218,7 +228,8 @@ public static partial class ThrowHelper
/// <exception cref="COMException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowCOMException<T>(string? message, Exception? innerException) => throw new COMException(message, innerException);
public static T ThrowCOMException<T>(string? message, Exception? innerException)
=> throw new COMException(message, innerException);
/// <summary>
/// Throws a new <see cref="COMException"/>.
@@ -259,7 +270,8 @@ public static partial class ThrowHelper
/// <exception cref="ExternalException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowExternalException<T>(string? message, Exception? innerException) => throw new ExternalException(message, innerException);
public static T ThrowExternalException<T>(string? message, Exception? innerException)
=> throw new ExternalException(message, innerException);
/// <summary>
/// Throws a new <see cref="ExternalException"/>.
@@ -270,7 +282,8 @@ public static partial class ThrowHelper
/// <exception cref="ExternalException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowExternalException<T>(string? message, int error) => throw new ExternalException(message, error);
public static T ThrowExternalException<T>(string? message, int error)
=> throw new ExternalException(message, error);
/// <summary>
/// Throws a new <see cref="FormatException"/>.
@@ -300,7 +313,8 @@ public static partial class ThrowHelper
/// <exception cref="FormatException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowFormatException<T>(string? message, Exception? innerException) => throw new FormatException(message, innerException);
public static T ThrowFormatException<T>(string? message, Exception? innerException)
=> throw new FormatException(message, innerException);
/// <summary>
/// Throws a new <see cref="InsufficientMemoryException"/>.
@@ -319,7 +333,8 @@ public static partial class ThrowHelper
/// <exception cref="InsufficientMemoryException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowInsufficientMemoryException<T>(string? message) => throw new InsufficientMemoryException(message);
public static T ThrowInsufficientMemoryException<T>(string? message)
=> throw new InsufficientMemoryException(message);
/// <summary>
/// Throws a new <see cref="InsufficientMemoryException"/>.
@@ -330,7 +345,8 @@ public static partial class ThrowHelper
/// <exception cref="InsufficientMemoryException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowInsufficientMemoryException<T>(string? message, Exception? innerException) => throw new InsufficientMemoryException(message, innerException);
public static T ThrowInsufficientMemoryException<T>(string? message, Exception? innerException)
=> throw new InsufficientMemoryException(message, innerException);
/// <summary>
/// Throws a new <see cref="InvalidDataException"/>.
@@ -360,7 +376,8 @@ public static partial class ThrowHelper
/// <exception cref="InvalidDataException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowInvalidDataException<T>(string? message, Exception? innerException) => throw new InvalidDataException(message, innerException);
public static T ThrowInvalidDataException<T>(string? message, Exception? innerException)
=> throw new InvalidDataException(message, innerException);
/// <summary>
/// Throws a new <see cref="InvalidOperationException"/>.
@@ -390,7 +407,8 @@ public static partial class ThrowHelper
/// <exception cref="InvalidOperationException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowInvalidOperationException<T>(string? message, Exception? innerException) => throw new InvalidOperationException(message, innerException);
public static T ThrowInvalidOperationException<T>(string? message, Exception? innerException)
=> throw new InvalidOperationException(message, innerException);
/// <summary>
/// Throws a new <see cref="LockRecursionException"/>.
@@ -420,7 +438,8 @@ public static partial class ThrowHelper
/// <exception cref="LockRecursionException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowLockRecursionException<T>(string? message, Exception? innerException) => throw new LockRecursionException(message, innerException);
public static T ThrowLockRecursionException<T>(string? message, Exception? innerException)
=> throw new LockRecursionException(message, innerException);
/// <summary>
/// Throws a new <see cref="MissingFieldException"/>.
@@ -450,7 +469,8 @@ public static partial class ThrowHelper
/// <exception cref="MissingFieldException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowMissingFieldException<T>(string? message, Exception? innerException) => throw new MissingFieldException(message, innerException);
public static T ThrowMissingFieldException<T>(string? message, Exception? innerException)
=> throw new MissingFieldException(message, innerException);
/// <summary>
/// Throws a new <see cref="MissingFieldException"/>.
@@ -461,7 +481,8 @@ public static partial class ThrowHelper
/// <exception cref="MissingFieldException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowMissingFieldException<T>(string? className, string? fieldName) => throw new MissingFieldException(className, fieldName);
public static T ThrowMissingFieldException<T>(string? className, string? fieldName)
=> throw new MissingFieldException(className, fieldName);
/// <summary>
/// Throws a new <see cref="MissingMemberException"/>.
@@ -491,7 +512,8 @@ public static partial class ThrowHelper
/// <exception cref="MissingMemberException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowMissingMemberException<T>(string? message, Exception? innerException) => throw new MissingMemberException(message, innerException);
public static T ThrowMissingMemberException<T>(string? message, Exception? innerException)
=> throw new MissingMemberException(message, innerException);
/// <summary>
/// Throws a new <see cref="MissingMemberException"/>.
@@ -502,7 +524,8 @@ public static partial class ThrowHelper
/// <exception cref="MissingMemberException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowMissingMemberException<T>(string? className, string? memberName) => throw new MissingMemberException(className, memberName);
public static T ThrowMissingMemberException<T>(string? className, string? memberName)
=> throw new MissingMemberException(className, memberName);
/// <summary>
/// Throws a new <see cref="MissingMethodException"/>.
@@ -532,7 +555,8 @@ public static partial class ThrowHelper
/// <exception cref="MissingMethodException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowMissingMethodException<T>(string? message, Exception? innerException) => throw new MissingMethodException(message, innerException);
public static T ThrowMissingMethodException<T>(string? message, Exception? innerException)
=> throw new MissingMethodException(message, innerException);
/// <summary>
/// Throws a new <see cref="MissingMethodException"/>.
@@ -543,7 +567,8 @@ public static partial class ThrowHelper
/// <exception cref="MissingMethodException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowMissingMethodException<T>(string? className, string? methodName) => throw new MissingMethodException(className, methodName);
public static T ThrowMissingMethodException<T>(string? className, string? methodName)
=> throw new MissingMethodException(className, methodName);
/// <summary>
/// Throws a new <see cref="NotSupportedException"/>.
@@ -573,7 +598,8 @@ public static partial class ThrowHelper
/// <exception cref="NotSupportedException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowNotSupportedException<T>(string? message, Exception? innerException) => throw new NotSupportedException(message, innerException);
public static T ThrowNotSupportedException<T>(string? message, Exception? innerException)
=> throw new NotSupportedException(message, innerException);
/// <summary>
/// Throws a new <see cref="ObjectDisposedException"/>.
@@ -583,7 +609,8 @@ public static partial class ThrowHelper
/// <exception cref="ObjectDisposedException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowObjectDisposedException<T>(string? objectName) => throw new ObjectDisposedException(objectName);
public static T ThrowObjectDisposedException<T>(string? objectName)
=> throw new ObjectDisposedException(objectName);
/// <summary>
/// Throws a new <see cref="ObjectDisposedException"/>.
@@ -594,7 +621,8 @@ public static partial class ThrowHelper
/// <exception cref="ObjectDisposedException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowObjectDisposedException<T>(string? objectName, Exception? innerException) => throw new ObjectDisposedException(objectName, innerException);
public static T ThrowObjectDisposedException<T>(string? objectName, Exception? innerException)
=> throw new ObjectDisposedException(objectName, innerException);
/// <summary>
/// Throws a new <see cref="ObjectDisposedException"/>.
@@ -605,7 +633,8 @@ public static partial class ThrowHelper
/// <exception cref="ObjectDisposedException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowObjectDisposedException<T>(string? objectName, string? message) => throw new ObjectDisposedException(objectName, message);
public static T ThrowObjectDisposedException<T>(string? objectName, string? message)
=> throw new ObjectDisposedException(objectName, message);
/// <summary>
/// Throws a new <see cref="OperationCanceledException"/>.
@@ -624,7 +653,8 @@ public static partial class ThrowHelper
/// <exception cref="OperationCanceledException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowOperationCanceledException<T>(string? message) => throw new OperationCanceledException(message);
public static T ThrowOperationCanceledException<T>(string? message)
=> throw new OperationCanceledException(message);
/// <summary>
/// Throws a new <see cref="OperationCanceledException"/>.
@@ -635,7 +665,8 @@ public static partial class ThrowHelper
/// <exception cref="OperationCanceledException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowOperationCanceledException<T>(string? message, Exception? innerException) => throw new OperationCanceledException(message, innerException);
public static T ThrowOperationCanceledException<T>(string? message, Exception? innerException)
=> throw new OperationCanceledException(message, innerException);
/// <summary>
/// Throws a new <see cref="OperationCanceledException"/>.
@@ -645,7 +676,8 @@ public static partial class ThrowHelper
/// <exception cref="OperationCanceledException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowOperationCanceledException<T>(CancellationToken token) => throw new OperationCanceledException(token);
public static T ThrowOperationCanceledException<T>(CancellationToken token)
=> throw new OperationCanceledException(token);
/// <summary>
/// Throws a new <see cref="OperationCanceledException"/>.
@@ -656,7 +688,8 @@ public static partial class ThrowHelper
/// <exception cref="OperationCanceledException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowOperationCanceledException<T>(string? message, CancellationToken token) => throw new OperationCanceledException(message, token);
public static T ThrowOperationCanceledException<T>(string? message, CancellationToken token)
=> throw new OperationCanceledException(message, token);
/// <summary>
/// Throws a new <see cref="OperationCanceledException"/>.
@@ -668,7 +701,9 @@ public static partial class ThrowHelper
/// <exception cref="OperationCanceledException">Thrown with the specified parameters.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowOperationCanceledException<T>(string? message, Exception? innerException, CancellationToken token) => throw new OperationCanceledException(message, innerException, token);
public static T ThrowOperationCanceledException<T>(string? message, Exception? innerException,
CancellationToken token)
=> throw new OperationCanceledException(message, innerException, token);
/// <summary>
/// Throws a new <see cref="PlatformNotSupportedException"/>.
@@ -687,7 +722,8 @@ public static partial class ThrowHelper
/// <exception cref="PlatformNotSupportedException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowPlatformNotSupportedException<T>(string? message) => throw new PlatformNotSupportedException(message);
public static T ThrowPlatformNotSupportedException<T>(string? message)
=> throw new PlatformNotSupportedException(message);
/// <summary>
/// Throws a new <see cref="PlatformNotSupportedException"/>.
@@ -698,7 +734,8 @@ public static partial class ThrowHelper
/// <exception cref="PlatformNotSupportedException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowPlatformNotSupportedException<T>(string? message, Exception? innerException) => throw new PlatformNotSupportedException(message, innerException);
public static T ThrowPlatformNotSupportedException<T>(string? message, Exception? innerException)
=> throw new PlatformNotSupportedException(message, innerException);
/// <summary>
/// Throws a new <see cref="SynchronizationLockException"/>.
@@ -717,7 +754,8 @@ public static partial class ThrowHelper
/// <exception cref="SynchronizationLockException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowSynchronizationLockException<T>(string? message) => throw new SynchronizationLockException(message);
public static T ThrowSynchronizationLockException<T>(string? message)
=> throw new SynchronizationLockException(message);
/// <summary>
/// Throws a new <see cref="SynchronizationLockException"/>.
@@ -728,7 +766,8 @@ public static partial class ThrowHelper
/// <exception cref="SynchronizationLockException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowSynchronizationLockException<T>(string? message, Exception? innerException) => throw new SynchronizationLockException(message, innerException);
public static T ThrowSynchronizationLockException<T>(string? message, Exception? innerException)
=> throw new SynchronizationLockException(message, innerException);
/// <summary>
/// Throws a new <see cref="TimeoutException"/>.
@@ -758,7 +797,8 @@ public static partial class ThrowHelper
/// <exception cref="TimeoutException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowTimeoutException<T>(string? message, Exception? innerException) => throw new TimeoutException(message, innerException);
public static T ThrowTimeoutException<T>(string? message, Exception? innerException)
=> throw new TimeoutException(message, innerException);
/// <summary>
/// Throws a new <see cref="UnauthorizedAccessException"/>.
@@ -777,7 +817,8 @@ public static partial class ThrowHelper
/// <exception cref="UnauthorizedAccessException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowUnauthorizedAccessException<T>(string? message) => throw new UnauthorizedAccessException(message);
public static T ThrowUnauthorizedAccessException<T>(string? message)
=> throw new UnauthorizedAccessException(message);
/// <summary>
/// Throws a new <see cref="UnauthorizedAccessException"/>.
@@ -788,7 +829,8 @@ public static partial class ThrowHelper
/// <exception cref="UnauthorizedAccessException">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowUnauthorizedAccessException<T>(string? message, Exception? innerException) => throw new UnauthorizedAccessException(message, innerException);
public static T ThrowUnauthorizedAccessException<T>(string? message, Exception? innerException)
=> throw new UnauthorizedAccessException(message, innerException);
/// <summary>
/// Throws a new <see cref="Win32Exception"/>.
@@ -839,5 +881,6 @@ public static partial class ThrowHelper
/// <exception cref="Win32Exception">Thrown with the specified parameter.</exception>
/// <returns>This method always throws, so it actually never returns a value.</returns>
[DoesNotReturn]
public static T ThrowWin32Exception<T>(string? message, Exception? innerException) => throw new Win32Exception(message, innerException);
}
public static T ThrowWin32Exception<T>(string? message, Exception? innerException)
=> throw new Win32Exception(message, innerException);
}