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

Serializing JObject results with NullReferenceException #66

Closed
pmbanka opened this issue Aug 8, 2017 · 4 comments
Closed

Serializing JObject results with NullReferenceException #66

pmbanka opened this issue Aug 8, 2017 · 4 comments

Comments

@pmbanka
Copy link

pmbanka commented Aug 8, 2017

I created a PR with failing unit test exposing the problem: #65

Starting test execution, please wait...
[xUnit.net 00:00:00.5834487]   Discovering: Hyperion.Tests
[xUnit.net 00:00:00.8800229]   Discovered:  Hyperion.Tests
[xUnit.net 00:00:01.5499118]   Starting:    Hyperion.Tests
[xUnit.net 00:00:01.9438699]     Hyperion.Tests.ISerializableTests.SkipNonSerializedAttributeIfNoSerilizedAttribute [SKIP]
[xUnit.net 00:00:01.9442333]       Not implemented yet
[xUnit.net 00:00:01.9531298]     Hyperion.Tests.ISerializableTests.ShouldNotThrowIfNoConstructorWithSerializationInfo [SKIP]
[xUnit.net 00:00:01.9533130]       Not implemented yet
Skipped  Hyperion.Tests.ISerializableTests.SkipNonSerializedAttributeIfNoSerilizedAttribute
Skipped  Hyperion.Tests.ISerializableTests.ShouldNotThrowIfNoConstructorWithSerializationInfo
[xUnit.net 00:00:02.4549861]     Hyperion.Tests.JsonObjectTests.CanSerializeSimpleJObject [FAIL]
[xUnit.net 00:00:02.4565330]       System.NullReferenceException : Object reference not set to an instance of an object.
[xUnit.net 00:00:02.4572192]       Stack Trace:
[xUnit.net 00:00:02.4578435]            at Hyperion.SerializerFactories.DictionarySerializerFactory.<>c__DisplayClass3_0.<BuildSerializer>b__1(Stream stream, Object obj, Serializer
Session session)
[xUnit.net 00:00:02.4590671]            at Hyperion.ValueSerializers.ObjectSerializer.WriteValue(Stream stream, Object value, SerializerSession session)
[xUnit.net 00:00:02.4591752]            at Hyperion.Serializer.Serialize(Object obj, Stream stream)
[xUnit.net 00:00:02.4592541]         JsonObjectTests.cs(25,0): at Hyperion.Tests.JsonObjectTests.CanSerializeSimpleJObject()
Failed   Hyperion.Tests.JsonObjectTests.CanSerializeSimpleJObject
Error Message:
 System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
   at Hyperion.SerializerFactories.DictionarySerializerFactory.<>c__DisplayClass3_0.<BuildSerializer>b__1(Stream stream, Object obj, SerializerSession session)
   at Hyperion.ValueSerializers.ObjectSerializer.WriteValue(Stream stream, Object value, SerializerSession session)
   at Hyperion.Serializer.Serialize(Object obj, Stream stream)
   at Hyperion.Tests.JsonObjectTests.CanSerializeSimpleJObject() in C:\repos\Hyperion\Hyperion.Tests\JsonObjectTests.cs:line 25
[xUnit.net 00:00:03.0441936]     Hyperion.Tests.CollectionTests.CanSerializeMultiDimentionalArray [SKIP]
[xUnit.net 00:00:03.0444410]       add support for multi dimentional arrays
Skipped  Hyperion.Tests.CollectionTests.CanSerializeMultiDimentionalArray
[xUnit.net 00:00:03.0831862]   Finished:    Hyperion.Tests

Total tests: 138. Passed: 134. Failed: 1. Skipped: 3.
Test execution time: 3.5277 Seconds
Test Run Failed.

@pmbanka
Copy link
Author

pmbanka commented Aug 8, 2017

I wanted to dig into the problem, but I don't know how to attach a debugger ;)

  1. opening sln in VS 2017 fails because of
C:\repos\Hyperion\Hyperion.FSharpTestTypes\Hyperion.FSharpTestTypes.fsproj : error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\FSharp.NET.Sdk\Sdk\Sdk.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
  1. Trying to debug in VSCode fails... I don't really know why (yet).

Any guidance would be appreciated.

@pmbanka
Copy link
Author

pmbanka commented Aug 8, 2017

The other question is, of course, whether I should expect JObject to be serializable by Hyperion at all :)

@pmbanka
Copy link
Author

pmbanka commented Aug 8, 2017

Ok, so I managed to get the debugger running (by removing all FSharp related stuff) and found out that:

  1. JObject is a Dictionary<string, JToken> so Hyperion tries to serialize it using DictionarySerializerFactory
  2. Support for dictionaries is unfinished Support for IDictionary #46

I feel like I simply should not expect JObject to be serializable by Hyperion at all. Is that correct?

@Efp95
Copy link

Efp95 commented Aug 1, 2018

Any update on this? I'm having a very similar problem to #72

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

2 participants