Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix duplicate registration of named tuples - #1464

#1464
Merged
AArnott merged 2 commits into
MessagePack-CSharp:masterMessagePack-CSharp/MessagePack-CSharp:masterfrom
honda-tatsuya:fix-tuplehonda-tatsuya/MessagePack-CSharp:fix-tupleCopy head branch name to clipboard
Nov 19, 2022
Merged

fix duplicate registration of named tuples#1464
AArnott merged 2 commits into
MessagePack-CSharp:masterMessagePack-CSharp/MessagePack-CSharp:masterfrom
honda-tatsuya:fix-tuplehonda-tatsuya/MessagePack-CSharp:fix-tupleCopy head branch name to clipboard

Conversation

@honda-tatsuya

@honda-tatsuya honda-tatsuya commented Jul 8, 2022

Copy link
Copy Markdown
Contributor

Example

using MessagePack;
using System.Collections.Generic;

[MessagePackObject]
public class Test
{
    [Key(0)] public Dictionary<((int A, int B) C, (int D, int E) F), ((int G, int H) I, (int J, int K) L)> Hoge;
    [Key(1)] public ((int M, int N) O, (int P, int Q) R)[,] Fuga;
}

Before

        static GeneratedResolverGetFormatterHelper()
        {
            lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(12)
            {
                { typeof(((int A, int B) C, (int D, int E) F)), 0 },
                { typeof(((int G, int H) I, (int J, int K) L)), 1 },
                { typeof(((int M, int N) O, (int P, int Q) R)), 2 },
                { typeof(((int M, int N) O, (int P, int Q) R)[,]), 3 },
                { typeof((int A, int B)), 4 },
                { typeof((int D, int E)), 5 },
                { typeof((int G, int H)), 6 },
                { typeof((int J, int K)), 7 },
                { typeof((int M, int N)), 8 },
                { typeof((int P, int Q)), 9 },
                { typeof(global::System.Collections.Generic.Dictionary<((int A, int B) C, (int D, int E) F), ((int G, int H) I, (int J, int K) L)>), 10 },
                { typeof(global::Test), 11 },
            };
        }

This is runtime error
ArgumentException: An item with the same key has already been added. Key: System.ValueTuple`2[System.Int32,System.Int32]

After

        static GeneratedResolverGetFormatterHelper()
        {
            lookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(5)
            {
                { typeof(((int, int), (int, int))), 0 },
                { typeof(((int, int), (int, int))[,]), 1 },
                { typeof((int, int)), 2 },
                { typeof(global::System.Collections.Generic.Dictionary<((int, int), (int, int)), ((int, int), (int, int))>), 3 },
                { typeof(global::Test), 4 },
            };
        }

@honda-tatsuya honda-tatsuya changed the title Fix order of Generic and Tuple fix duplicate registration of named tuples Jul 11, 2022
@neuecc

neuecc commented Jul 11, 2022

Copy link
Copy Markdown
Member

thanks, it seems good.
approve to merge.

@AArnott

AArnott commented Jul 14, 2022

Copy link
Copy Markdown
Collaborator

@honda-tatsuya Thanks for your contribution. Can you please review the test failures and address them?

@github-actions

github-actions Bot commented Nov 1, 2022

Copy link
Copy Markdown
Contributor

This pull request is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions Bot closed this Nov 7, 2022
@neuecc neuecc reopened this Nov 18, 2022
@honda-tatsuya

Copy link
Copy Markdown
Contributor Author

@AArnott I fixed it. sorry for the delay.

@AArnott
AArnott merged commit 5a138c4 into MessagePack-CSharp:master Nov 19, 2022
This was referenced Jun 11, 2026
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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.