diff --git a/Octokit/Http/SimpleJsonSerializer.cs b/Octokit/Http/SimpleJsonSerializer.cs index 081383d7..a022d141 100644 --- a/Octokit/Http/SimpleJsonSerializer.cs +++ b/Octokit/Http/SimpleJsonSerializer.cs @@ -30,14 +30,12 @@ namespace Octokit.Internal [SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification = "Need to support .NET 2")] protected override bool TrySerializeUnknownTypes(object input, out object output) { - if (input == null) throw new ArgumentNullException("input"); - output = null; - Type type = input.GetType(); - if (type.FullName == null) - return false; - IDictionary obj = new JsonObject(); - IDictionary getters = GetCache[type]; - foreach (KeyValuePair getter in getters) + Ensure.ArgumentNotNull(input, "input"); + + var type = input.GetType(); + var jsonObject = new JsonObject(); + var getters = GetCache[type]; + foreach (var getter in getters) { if (getter.Value != null) { @@ -45,10 +43,10 @@ namespace Octokit.Internal if (value == null) continue; - obj.Add(MapClrMemberNameToJsonFieldName(getter.Key), value); + jsonObject.Add(MapClrMemberNameToJsonFieldName(getter.Key), value); } } - output = obj; + output = jsonObject; return true; }