Skip to content

Commit ef083ba

Browse files
committed
Remove the trow when enum value isn't present in favour of a default value of the enum. It changes the behaviour for #1614
1 parent 8943147 commit ef083ba

File tree

2 files changed

+842
-843
lines changed

2 files changed

+842
-843
lines changed

src/RestSharp/Extensions/ReflectionExtensions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ public static bool IsSubclassOfRawGeneric(this Type toCheck, Type generic)
9393
if (enumValueAsUnderlyingType != null && Enum.IsDefined(type, enumValueAsUnderlyingType))
9494
ret = (Enum) Enum.ToObject(type, enumValueAsUnderlyingType);
9595

96-
if (ret == null)
97-
throw new ArgumentOutOfRangeException(value + " undefined for " + type);
98-
return ret;
96+
return ret ?? Activator.CreateInstance(type);
9997
}
10098
}
10199
}

0 commit comments

Comments
 (0)