Move reflection calls until after branches that may mean they're unused

A handful of cases where reflection calls are made prior to branches that
might lead to the results not being used.
This commit is contained in:
Jon Hanna
2015-12-17 18:27:12 +00:00
parent 9d8e59589b
commit dbbe944b19
4 changed files with 17 additions and 22 deletions
@@ -99,10 +99,6 @@ namespace Newtonsoft.Json.Converters
/// <returns>The object value.</returns>
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
Type t = (ReflectionUtils.IsNullableType(objectType))
? Nullable.GetUnderlyingType(objectType)
: objectType;
if (reader.TokenType == JsonToken.Null)
{
if (!ReflectionUtils.IsNullable(objectType))
@@ -131,6 +127,10 @@ namespace Newtonsoft.Json.Converters
throw JsonSerializationException.Create(reader, "Unexpected token parsing binary. Expected String or StartArray, got {0}.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
}
Type t = (ReflectionUtils.IsNullableType(objectType))
? Nullable.GetUnderlyingType(objectType)
: objectType;
#if !NET20
if (t.AssignableToTypeName(BinaryTypeName))
{