Closed mistyn8 closed 3 years ago
the associated log error (maybe the valueConvertor?)
Failed to convert UmbNav {ex}
--
Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Int32'. Path '[1].id', line 17, position 14. ---> System.InvalidCastException: Null object cannot be converted to a value type. at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType) --- End of inner exception stack trace --- 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.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 UmbNav.Core.ValueConverters.UmbNavV8ValueConverter.ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, Object inter, Boolean preview)
I will take a look a little later on tonight when I finish work :)
public int Id { get; set; } => public int? Id { get; set; } ??
I'll have a play to see if that's it.
When you clone down, if you mark the v9 test site as startup and run uSync import it should restore my test data =]
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
[Obsolete("This is here purely for legacy reasons, please use the Key or Udi property as this is unreliable")]
public int Id { get; set; } = 0;
Seems to allow rendering.. :-)
although
<span class="nav-link" rel="test" href="">Label goes here</span>
might be the taghelper needs a tweak?
ps Had to update the USync dependency to get the import to complete.
Pull Request #40
Interesting the span shouldn't contain "href" that's for sure 😕
updated the pull request with a tweak for labels :-)
@mistyn8 Great worked as expected!
I've released 1.0.3 should be on nuget shortly =]
Thanks!
Which exact Umbraco version are you using? For example: 8.7.0 - don't just write v8 or v9
Umb 9.0.0 umbNav 1.0.0.2
Bug summary
Adding a lablel in the tree causes System.Linq.EmptyPartition`1[UmbNav.Core.Models.UmbNavItem] to be returned when querying the property for rendering. raw json below if that helps?
Specifics
No response
Steps to reproduce
Add a label
Expected result / actual result
labels should be possible.