-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Proposal
- Create a new internal
Verify
class that makes use of modern features like e.g. the[CallerArgumentExpression]
attribute. - Replace all existing argument checks.
Intention
Removes boilerplate code by instructing the compiler to automatically pass argument expressions to the check function.
Improves quality of exception messages.
Example
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void NotNull([NotNull] object? obj, [CallerArgumentExpression(nameof(obj))] string? paramName = null)
{
#if NET
ArgumentNullException.ThrowIfNull(obj, paramName);
#else
if (obj is null)
{
throw new ArgumentNullException(paramName);
}
#endif
}
Metadata
Metadata
Assignees
Labels
No labels