JamesNK / Newtonsoft.Json

Json.NET is a popular high-performance JSON framework for .NET
https://www.newtonsoft.com/json
MIT License
10.74k stars 3.25k forks source link

JsonSerializerInternalReader EnsureType shows confusing message #1844

Closed Yoztastic closed 5 years ago

Yoztastic commented 6 years ago

The exception that is thrown in JsonSerializerInternalReader line 989

....EnsureType....           
 catch (Exception ex)
  {
    throw JsonSerializationException.Create(reader, "Error converting value {0} to type '{1}'.".FormatWith(CultureInfo.InvariantCulture, 
     MiscellaneousUtils.FormatValueForPrint(value), targetType), ex);
  } 

would it not be more useful to change targetType to targetType.FullName? As things stand it always emits 'System.Type' which is not very informative?

JamesNK commented 6 years ago

What platform is this on? ToString on Type should return FullName.