eiriktsarpalis/PolyType

Test cases assume that multi-dimensional arrays cannot be deserialized

Closed this issue · 4 comments

This is one of several test cases that my msgpack library is failing because my library can _de_serialize it:

https://github.com/eiriktsarpalis/typeshape-csharp/blob/7ed230930447d8e90463cf2c265054227f7a72e3/src/TypeShape.TestCases/TestTypes.cs#L105

Your test case says this type has no constructor:

https://github.com/eiriktsarpalis/typeshape-csharp/blob/7ed230930447d8e90463cf2c265054227f7a72e3/src/TypeShape.TestCases/TestCase.cs#L87-L92

Which your test pattern then uses to expect deserialization to throw:

https://github.com/eiriktsarpalis/typeshape-csharp/blob/7ed230930447d8e90463cf2c265054227f7a72e3/tests/TypeShape.Tests/JsonTests.cs#L75-L78

Why does it expect deserialization to fail for this? Multi-dimensional arrays are not only constructible, my library is already doing it. :)

The property is meant to reflect that the shape has no collection construction strategy. If the visitor is specializing multi-dimensional arrays, then correspondingly the tests would need to specialize that as well.

For the case of Json, I'm filtering out multi-dimensional arrays because the STJ baseline doesn't support them:

https://github.com/eiriktsarpalis/typeshape-csharp/blob/0b03b2ac2968e39885ba6dfa217b4672bc357cc1/tests/TypeShape.Tests/JsonTests.cs#L16-L19

And then I use a specialized unit test for the types:

https://github.com/eiriktsarpalis/typeshape-csharp/blob/0b03b2ac2968e39885ba6dfa217b4672bc357cc1/tests/TypeShape.Tests/JsonTests.cs#L289-L325

In my workaround, I've stopped using your HasConstructors method. I've actually copied it and removed the multi-dimensional test. It sounds like from what you're saying that that's the best fix and we should close the issue now. Is that right?

I think we can close it for now, but there's definitely room for refininement in how we annotate these test types.