Skip to content

Commit 19cff15

Browse files
authored
Do not throw ArgumenNullException in ConfigSettingEntry.GetAcceptedValues (#89)
This PR removes the ArgumenNullException present in ConfigSettingEntry.GetAcceptedValues(AcceptableValueBase values), enforcing the use of both MinValue and MaxValue for custom range classes (see issue's comments for a in-depth explanation) Fixes #88
1 parent a6c7d75 commit 19cff15

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

ConfigurationManager.Shared/ConfigSettingEntry.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Linq;
@@ -51,10 +51,9 @@ private void GetAcceptableValues(AcceptableValueBase values)
5151
else
5252
{
5353
var minProp = t.GetProperty(nameof(AcceptableValueRange<bool>.MinValue), BindingFlags.Instance | BindingFlags.Public);
54-
if (minProp != null)
54+
var maxProp = t.GetProperty(nameof(AcceptableValueRange<bool>.MaxValue), BindingFlags.Instance | BindingFlags.Public);
55+
if (minProp != null && maxProp != null)
5556
{
56-
var maxProp = t.GetProperty(nameof(AcceptableValueRange<bool>.MaxValue), BindingFlags.Instance | BindingFlags.Public);
57-
if (maxProp == null) throw new ArgumentNullException(nameof(maxProp));
5857
AcceptableValueRange = new KeyValuePair<object, object>(minProp.GetValue(values, null), maxProp.GetValue(values, null));
5958
ShowRangeAsPercent = (AcceptableValueRange.Key.Equals(0) || AcceptableValueRange.Key.Equals(1)) && AcceptableValueRange.Value.Equals(100) ||
6059
AcceptableValueRange.Key.Equals(0f) && AcceptableValueRange.Value.Equals(1f);

0 commit comments

Comments
 (0)