Skip to content

Commit 1aae194

Browse files
committed
feat: implement DisallowNothing method in Guard class
1 parent d63d596 commit 1aae194

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Updated .NET targets and dependencies
10+
- Updated .NET targets and dependencies.
11+
- Implemented `Guard::DisallowNothing` method.
1112

1213
## [6.4.6] - 2024-06-01
1314

src/SharpX/Utilities/Guard.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,10 @@ public static void DisallowMalformedGuid(string argumentName, string value)
7979
try { Guid.Parse(value); }
8080
catch { throw new ArgumentException($"{argumentName} must be a well formed GUID.", argumentName); }
8181
}
82+
83+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
84+
public static void DisallowNothing<T>(string argumentName, Maybe<T> value)
85+
{
86+
if (value.Tag == MaybeType.Nothing) throw new ArgumentException($"{argumentName} cannot be nothing.", argumentName);
87+
}
8288
}

0 commit comments

Comments
 (0)