Skip to content

Commit

Permalink
SimpleJson: throw exception in case of default constructor not found
Browse files Browse the repository at this point in the history
  • Loading branch information
bid-soft committed Jul 31, 2024
1 parent a9e3229 commit c62e1af
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion JotunnLib/Utils/SimpleJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,10 @@ public virtual object DeserializeObject(object value, Type type)
obj = value;
else
{
obj = ConstructorCache[type]();
var constructorDelegate = ConstructorCache[type];
if (constructorDelegate != null) obj = constructorDelegate();
else throw new MissingMethodException($"No default constructor found for {type}");

foreach (KeyValuePair<string, KeyValuePair<Type, ReflectionUtils.SetDelegate>> setter in SetCache[type])
{
object jsonValue;
Expand Down

0 comments on commit c62e1af

Please sign in to comment.