Skip to content

Commit f76a391

Browse files
Merge pull request #25 from tintoy/tintoy/renor-nre
Avoid NullReferenceException if "params" property is null.
2 parents b1f0d7e + 697c22f commit f76a391

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/JsonRpc/Client/Request.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class Request
1212

1313
public string Method { get; set; }
1414

15+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
1516
public object Params { get; set; }
1617
}
17-
}
18+
}

src/JsonRpc/Reciever.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected virtual Renor GetRenor(JToken @object)
7878
}
7979

8080
var hasParams = request.TryGetValue("params", out var @params);
81-
if (hasParams && @params.Type != JTokenType.Array && @params.Type != JTokenType.Object)
81+
if (hasParams && @params?.Type != JTokenType.Array && @params?.Type != JTokenType.Object)
8282
{
8383
return new InvalidRequest(requestId, "Invalid params");
8484
}
@@ -95,4 +95,4 @@ protected virtual Renor GetRenor(JToken @object)
9595
}
9696
}
9797
}
98-
}
98+
}

0 commit comments

Comments
 (0)