From 3847534daa7192bec2f710902842e33b6b5c8f31 Mon Sep 17 00:00:00 2001 From: Hinton Date: Thu, 28 Sep 2023 21:00:40 +0200 Subject: [PATCH] Apply review suggestions --- src/Core/Constants.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Core/Constants.cs b/src/Core/Constants.cs index b050b92e5175..ceeeb4809b75 100644 --- a/src/Core/Constants.cs +++ b/src/Core/Constants.cs @@ -39,13 +39,18 @@ public class RangeConstant public int Min { get; } public int Max { get; } - public RangeConstant(int min, int max, int def) + public RangeConstant(int min, int max, int defaultValue) { - Default = def; + Default = defaultValue; Min = min; Max = max; - if (!InsideRange(def)) + if (Min > Max) + { + throw new ArgumentOutOfRangeException($"{Min} is larger than {Max}."); + } + + if (!InsideRange(defaultValue)) { throw new ArgumentOutOfRangeException($"{Default} is outside allowed range of {Min}-{Max}."); }