Created
June 6, 2021 13:27
-
-
Save rstropek/e883d7590ad7f2cc5e7c679fdabe51c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nullable enable | |
using System; | |
using System.Runtime.CompilerServices; | |
var x = 5; | |
Verify.Lower(x * 2, Convert.ToInt32(Math.Floor(Math.PI))); | |
public static class Verify | |
{ | |
public static void Lower(int argument, int maxValue, | |
[CallerArgumentExpression("argument")] string? argumentExpression = null, | |
[CallerArgumentExpression("maxValue")] string? maxValueExpression = null) | |
{ | |
if (argument > maxValue) | |
{ | |
throw new ArgumentOutOfRangeException(nameof(argument), | |
$"{argumentExpression} must be lower or equal {maxValueExpression}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment