Skip to content

Commit

Permalink
Do not throw ArgumenNullException in ConfigSettingEntry.GetAcceptedVa…
Browse files Browse the repository at this point in the history
…lues (#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
  • Loading branch information
MrAgeo committed Apr 5, 2024
1 parent a6c7d75 commit 19cff15
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ConfigurationManager.Shared/ConfigSettingEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -51,10 +51,9 @@ private void GetAcceptableValues(AcceptableValueBase values)
else
{
var minProp = t.GetProperty(nameof(AcceptableValueRange<bool>.MinValue), BindingFlags.Instance | BindingFlags.Public);
if (minProp != null)
var maxProp = t.GetProperty(nameof(AcceptableValueRange<bool>.MaxValue), BindingFlags.Instance | BindingFlags.Public);
if (minProp != null && maxProp != null)
{
var maxProp = t.GetProperty(nameof(AcceptableValueRange<bool>.MaxValue), BindingFlags.Instance | BindingFlags.Public);
if (maxProp == null) throw new ArgumentNullException(nameof(maxProp));
AcceptableValueRange = new KeyValuePair<object, object>(minProp.GetValue(values, null), maxProp.GetValue(values, null));
ShowRangeAsPercent = (AcceptableValueRange.Key.Equals(0) || AcceptableValueRange.Key.Equals(1)) && AcceptableValueRange.Value.Equals(100) ||
AcceptableValueRange.Key.Equals(0f) && AcceptableValueRange.Value.Equals(1f);
Expand Down

0 comments on commit 19cff15

Please sign in to comment.