question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue deserializing List<object> with null value

See original GitHub issue

I have the following example class:

public class TestClass
{
	public List<object> TestProperty { get; set; } = new List<object> { null };
}

Serializing it generates the following xml:

<?xml version="1.0" encoding="UTF-8"?>
<Program-TestClass xmlns="clr-namespace:XmlMigrator;assembly=XmlMigrator" xmlns:sys="https://extendedxmlserializer.github.io/system">
   <TestProperty>
      <Capacity>4</Capacity>
      <Null xmlns="https://extendedxmlserializer.github.io/v2" />
   </TestProperty>
</Program-TestClass>

When deserializing it I get the following exception:

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at ExtendedXmlSerializer.Core.Sources.CacheBase`2.Get(TKey key)
   at ExtendedXmlSerializer.ExtensionModel.References.DeferredContents.Get(TypeInfo parameter)
   at ExtendedXmlSerializer.ContentModel.RuntimeSerialization.Get(TypeInfo parameter)
   at ExtendedXmlSerializer.ContentModel.RuntimeSerializer.Get(IFormatReader reader)
   at ExtendedXmlSerializer.ContentModel.SerializerAdapter`1.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ExtensionModel.RootInstanceExtension.Serializer.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ExtensionModel.References.CircularReferenceEnabledSerialization.Container.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ContentModel.Serializer`1.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ContentModel.Serializer`1.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ContentModel.Collections.CollectionContentsHandler.Handle(IListInnerContent contents, IReader reader)
   at ExtendedXmlSerializer.ContentModel.Content.InnerContentServices.Handle(IListInnerContent contents, IReader reader)
   at ExtendedXmlSerializer.ContentModel.Collections.CollectionInnerContentHandler.Execute(IInnerContent parameter)
   at ExtendedXmlSerializer.Core.SelectedCommand`1.Execute(T parameter)
   at ExtendedXmlSerializer.ContentModel.Content.InnerContentReader.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ContentModel.Serializer`1.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ExtensionModel.References.ReferenceReader.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ExtensionModel.References.ReferenceSerializer.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ContentModel.Serializer`1.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ContentModel.Members.MemberSerializer.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ContentModel.Members.MemberHandler.Handle(IInnerContent contents, IMemberSerializer member)
   at ExtendedXmlSerializer.ContentModel.Content.InnerContentServices.Handle(IInnerContent contents, IMemberSerializer member)
   at ExtendedXmlSerializer.ContentModel.Members.MemberInnerContentHandler.IsSatisfiedBy(IInnerContent parameter)
   at ExtendedXmlSerializer.ContentModel.Members.MemberInnerContentHandler.Execute(IInnerContent parameter)
   at ExtendedXmlSerializer.ContentModel.Content.InnerContentReader.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ContentModel.Serializer`1.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ExtensionModel.References.ReferenceReader.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ExtensionModel.References.ReferenceSerializer.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ContentModel.SerializerAdapter`1.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ExtensionModel.RootInstanceExtension.Serializer.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.ExtensionModel.References.CircularReferenceEnabledSerialization.Container.Get(IFormatReader parameter)
   at ExtendedXmlSerializer.Read`1.Get(T parameter)
   at ExtendedXmlSerializer.Serializer`2.Deserialize(TRead reader)
   at ExtendedXmlSerializer.ExtensionModel.Xml.ExtendedXmlSerializer.Deserialize(XmlReader reader)
   at XmlMigrator.Program.Main() in C:\...\Program.cs:line 159

ExtendedXmlSerializer version: 2.1.6

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bpaczkowskicommented, Sep 11, 2018

Clearing the cache indeed worked. The reported issue is also fixed, thanks for the quick response!

0reactions
Mike-E-angelocommented, Sep 11, 2018

OK… I’ve pushed 2.1.7. It should be public here in the next hour. Please let me know if you run into any problems and I will help out to see what’s wrong. Closing this issue for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - JSON (deserialized) sends null values to list
I deserialize using my List to a seperate var. var o365IpVerion = JsonConvert.DeserializeObject<List<ConvertJsonIP>>(o365IP);. This code shows ...
Read more >
JsonSerializerOptions.IgnoreNullValues Property
Gets or sets a value that indicates whether null values are ignored during serialization and deserialization. The default value is false.
Read more >
Pro Objective-C - Page 226 - Google Books Result
Property List Deserialization NSError *errorStr; NSDictionary *plist ... If the value NULL is provided, then it is not necessary to know the format....
Read more >
Java EE 8: Only What's New: Level up quickly on the latest ...
... the JSON value will be deserialized to the corresponding default Java type as shown in the table. JSON Value Java Type object...
Read more >
Python How-To: 63 Techniques to Improve Your Python Code
9.3.4 json.loads('false') # output: False Boolean value json.loads('null') is None # output: True JSON null to Python None These strings represent JSON data ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found