diff --git a/StabilityMatrix.Core/Extensions/NullableExtensions.cs b/StabilityMatrix.Core/Extensions/NullableExtensions.cs
index aa644fb9..64264ef6 100644
--- a/StabilityMatrix.Core/Extensions/NullableExtensions.cs
+++ b/StabilityMatrix.Core/Extensions/NullableExtensions.cs
@@ -25,4 +25,23 @@ public static class NullableExtensions
}
return obj;
}
+
+ ///
+ /// Unwraps a nullable struct object, throwing an exception if it is null.
+ ///
+ ///
+ /// Thrown if () is null.
+ ///
+ [DebuggerStepThrough]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static T Unwrap([NotNull] this T? obj, [CallerArgumentExpression("obj")] string? paramName = null)
+ where T : struct
+ {
+ if (obj is null)
+ {
+ throw new ArgumentNullException(paramName, $"Unwrap of a null value ({typeof(T)}) {paramName}.");
+ }
+ return obj.Value;
+ }
}