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

Fixed nullable embedded types are being added to generated resolver #1556

Merged
merged 2 commits into from Mar 11, 2023

Conversation

Scormave
Copy link
Contributor

@Scormave Scormave commented Jan 26, 2023

If some embedded reference type, such as byte[] is defined as nullable in MessagePackObject, it starts to appear in generated resolver. But, generated formatter for byte[] (ArrayFormatter) is not binary compatible with embedded formatter (ByteArrayFormatter).
This is what is generated from NullableTest before the fix:

        static GeneratedResolverGetFormatterHelper()
        {
            lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(18)
            {
                { typeof(byte[]), 0 },
                { typeof(global::System.Collections.Generic.List<byte[]>), 1 },
                { typeof(global::System.Collections.Generic.List<global::TestData2.A>), 2 },
                { typeof(global::System.Collections.Generic.List<global::TestData2.B>), 3 },
                { typeof(int[]), 4 },
                { typeof(global::TestData2.Nest1.Id), 5 },
                { typeof(global::TestData2.Nest2.Id), 6 },
                { typeof(global::TestData2.A), 7 },
                { typeof(global::TestData2.B), 8 },
                { typeof(global::TestData2.C), 9 },
                { typeof(global::TestData2.Nest1), 10 },
                { typeof(global::TestData2.Nest1.IdType), 11 },
                { typeof(global::TestData2.Nest2), 12 },
                { typeof(global::TestData2.Nest2.IdType), 13 },
                { typeof(global::TestData2.NullableTest), 14 },
                { typeof(global::TestData2.PropNameCheck1), 15 },
                { typeof(global::TestData2.PropNameCheck2), 16 },
                { typeof(global::TestData2.Record), 17 },
            };
        }

After the fix it looks like this:

        static GeneratedResolverGetFormatterHelper()
        {
            lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(16)
            {
                { typeof(global::System.Collections.Generic.List<byte[]>), 0 },
                { typeof(global::System.Collections.Generic.List<global::TestData2.A>), 1 },
                { typeof(global::System.Collections.Generic.List<global::TestData2.B>), 2 },
                { typeof(global::TestData2.Nest1.Id), 3 },
                { typeof(global::TestData2.Nest2.Id), 4 },
                { typeof(global::TestData2.A), 5 },
                { typeof(global::TestData2.B), 6 },
                { typeof(global::TestData2.C), 7 },
                { typeof(global::TestData2.Nest1), 8 },
                { typeof(global::TestData2.Nest1.IdType), 9 },
                { typeof(global::TestData2.Nest2), 10 },
                { typeof(global::TestData2.Nest2.IdType), 11 },
                { typeof(global::TestData2.NullableTest), 12 },
                { typeof(global::TestData2.PropNameCheck1), 13 },
                { typeof(global::TestData2.PropNameCheck2), 14 },
                { typeof(global::TestData2.Record), 15 },
            };
        }

@AArnott
Copy link
Collaborator

AArnott commented Mar 11, 2023

/azp run

@AArnott AArnott merged commit 81199b1 into MessagePack-CSharp:develop Mar 11, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants