Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer exception when serializing a collection of the objects with a null element #34

Closed
nikolaygekht opened this issue Feb 12, 2021 · 2 comments

Comments

@nikolaygekht
Copy link

Example code:

List<int?> l = new List<int?>() { 1, null, 2 };
using (var ms1 = new MemoryStream())
{
    BinaronConvert.Serialize(l, ms1);
    using (var ms2 = new MemoryStream(ms1.ToArray()))
    {
          var l1 = BinaronConvert.Deserialize<List<int?>>(ms2);
    }
}

Serialization causes the null pointer exception.

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Binaron.Serializer
  StackTrace:
   at Binaron.Serializer.Serializer.WriteObject[T](WriterState writer, T val) in D:\develop\3rdparty\Binaron.Serializer\Binaron.Serializer\src\Binaron.Serializer\Serializer.cs:line 105
@nikolaygekht
Copy link
Author

I am going to take a look at this as a part of my update of the pull request #33

nikolaygekht added a commit to nikolaygekht/Binaron.Serializer that referenced this issue Feb 12, 2021
nikolaygekht added a commit to nikolaygekht/Binaron.Serializer that referenced this issue Feb 12, 2021
nikolaygekht added a commit to nikolaygekht/Binaron.Serializer that referenced this issue Feb 12, 2021
…ugh for var x = new T() { e1, e2, e3 } syntax.

- add debug code

- refactor the method of restoring IEnumerable with Add method (zachsaw#31)
- support of nullable in collections and as properties (zachsaw#34, zachsaw#35, zachsaw#36)
nikolaygekht added a commit to nikolaygekht/Binaron.Serializer that referenced this issue Feb 12, 2021
* - add support of IEnumerable with Add method (i.e. implementation enough for var x = new T() { e1, e2, e3 } syntax.
- add debug code

* - refactor the method of restoring IEnumerable with Add method (zachsaw#31)
- support of nullable in collections and as properties (zachsaw#34, zachsaw#35, zachsaw#36)

Co-authored-by: Nikolay Gekht <[email protected]>
nikolaygekht added a commit to nikolaygekht/Binaron.Serializer that referenced this issue Feb 12, 2021
- add support of IEnumerable with Add method (i.e. implementation enough for var x = new T() { e1, e2, e3 } syntax.
- refactor the method of restoring IEnumerable with Add method (zachsaw#31)
- support of nullable in collections and as properties (zachsaw#34, zachsaw#35, zachsaw#36)
nikolaygekht added a commit to nikolaygekht/Binaron.Serializer that referenced this issue Feb 12, 2021
- add support of IEnumerable with Add method (i.e. implementation enough for var x = new T() { e1, e2, e3 } syntax.
- refactor the method of restoring IEnumerable with Add method (zachsaw#31)
- support of nullable in collections and as properties (zachsaw#34, zachsaw#35, zachsaw#36)
nikolaygekht added a commit to nikolaygekht/Binaron.Serializer that referenced this issue Feb 12, 2021
- add support of IEnumerable with Add method (i.e. implementation enough for var x = new T() { e1, e2, e3 } syntax.
- refactor the method of restoring IEnumerable with Add method (zachsaw#31)
- support of nullable in collections and as properties (zachsaw#34, zachsaw#35, zachsaw#36)
nikolaygekht added a commit to nikolaygekht/Binaron.Serializer that referenced this issue Feb 12, 2021
* - add support of IEnumerable with Add method (i.e. implementation enough for var x = new T() { e1, e2, e3 } syntax.
- add debug code

* - refactor the method of restoring IEnumerable with Add method (zachsaw#31)
- support of nullable in collections and as properties (zachsaw#34, zachsaw#35, zachsaw#36)

Co-authored-by: Nikolay Gekht <[email protected]>
zachsawcs added a commit that referenced this issue Feb 16, 2021
* - add support of IEnumerable with Add method (i.e. implementation enough for var x = new T() { e1, e2, e3 } syntax.
- add debug code

* - refactor the method of restoring IEnumerable with Add method (#31)
- support of nullable in collections and as properties (#34, #35, #36)

Co-authored-by: Nikolay Gekht <[email protected]>
nikolaygekht added a commit to nikolaygekht/Binaron.Serializer that referenced this issue Feb 17, 2021
* Fix nullables and add support for IEnumerable with Add method

* - add support of IEnumerable with Add method (i.e. implementation enough for var x = new T() { e1, e2, e3 } syntax.
- add debug code

* - refactor the method of restoring IEnumerable with Add method (zachsaw#31)
- support of nullable in collections and as properties (zachsaw#34, zachsaw#35, zachsaw#36)

Co-authored-by: Nikolay Gekht <[email protected]>

* v4.1.0

Co-authored-by: Zach Saw <[email protected]>
Co-authored-by: Nikolay Gekht <[email protected]>
Co-authored-by: Zach Saw <[email protected]>
@nikolaygekht
Copy link
Author

I confirm that it is fixed in current master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant