Nikey646 / VndbSharp

A C# Vndb API Library. #OriginalNamingScheme
MIT License
18 stars 4 forks source link

Crash when doing GetProducerAsync #58

Closed micah686 closed 4 years ago

micah686 commented 4 years ago

When you do a GetProducerAsync with producer ID 1, an exception is thrown.

var producers = await this._client.GetProducerAsync(VndbFilters.Id.Equals(1), VndbFlags.FullProducer);
Newtonsoft.Json.JsonSerializationException
  HResult=0x80131500
  Message=Error converting value "Yamitsu" to type 'System.Collections.ObjectModel.ReadOnlyCollection`1[System.String]'. Path 'items[0].aliases', line 1, position 410.
  Source=Newtonsoft.Json
  StackTrace:
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at VndbSharp.Extensions.StringExtensions.FromJson[T](String json) in C:\Users\Micah\source\repos\VnManager\src\VndbSharp\VndbSharp\Extensions\StringExtensions.cs:line 19
   at VndbSharp.Vndb.<SendGetRequestInternalAsync>d__57`1.MoveNext() in C:\Users\Micah\source\repos\VnManager\src\VndbSharp\VndbSharp\Vndb.Helpers.cs:line 198
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at VndbSharp.Vndb.<GetInternalAsync>d__43`1.MoveNext() in C:\Users\Micah\source\repos\VnManager\src\VndbSharp\VndbSharp\Vndb.GetMethods.cs:line 88
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at VndbSharp.Vndb.<GetProducerAsync>d__36.MoveNext() in C:\Users\Micah\source\repos\VnManager\src\VndbSharp\VndbSharp\Vndb.GetMethods.cs:line 34
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at VndbConsole.Program.<GetProducerAsync>d__5.MoveNext() in C:\Users\Micah\source\repos\VnManager\src\VndbSharp\VndbConsoleCore\Program.cs:line 191
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at VndbConsole.Program.<MainAsync>d__1.MoveNext() in C:\Users\Micah\source\repos\VnManager\src\VndbSharp\VndbConsoleCore\Program.cs:line 39
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at VndbConsole.Program.Main(String[] args) in C:\Users\Micah\source\repos\VnManager\src\VndbSharp\VndbConsoleCore\Program.cs:line 23

  This exception was originally thrown at this call stack:
    Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(object, System.Type, System.Type)
    Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(object, System.Globalization.CultureInfo, System.Type)
    Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(Newtonsoft.Json.JsonReader, object, System.Globalization.CultureInfo, Newtonsoft.Json.Serialization.JsonContract, System.Type)

Inner Exception 1:
ArgumentException: Could not cast or convert from System.String to System.Collections.ObjectModel.ReadOnlyCollection`1[System.String].
Nikey646 commented 4 years ago

Fixed in https://github.com/Nikey646/VndbSharp/commit/3711862524943e789696a50c1827c65cb3717e42