Skip to content

Fix serializing BigInteger and Decimal#2061

Merged
AArnott merged 7 commits intoMessagePack-CSharp:developfrom
AlanLiu90:Fix2060
Nov 11, 2024
Merged

Fix serializing BigInteger and Decimal#2061
AArnott merged 7 commits intoMessagePack-CSharp:developfrom
AlanLiu90:Fix2060

Conversation

@AlanLiu90
Copy link
Contributor

Fix #2060

@AArnott
Copy link
Collaborator

AArnott commented Nov 11, 2024

Interesting that this bug has been around for a long time, and just last week I found and fixed it over in Nerdbank.MessagePack.
Although I see now I didn't even fix it optimally, so I'm fixing it further at AArnott/Nerdbank.MessagePack#64.

Your fix isn't quite right either. I'm preparing a change to finish the fix.

Copy link
Collaborator

@AArnott AArnott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing. Just a question about the test.

Comment on lines 92 to 98
var x = ParallelEnumerable
.Range(start, end)
.Aggregate(
() => System.Numerics.BigInteger.One,
(localProduct, i) => localProduct * i,
(totalProduct, localProduct) => totalProduct * localProduct,
finalProduct => finalProduct);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid factorial computation for our test, as that's irrelevant, and instead just initialize a very large number? Maybe using Math.Pow(300,300) or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I just committed a simpler test case.

Copy link
Collaborator

@AArnott AArnott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Thanks

@AArnott AArnott changed the title Fix serializing BigInteger Fix serializing BigInteger and Decimal Nov 11, 2024
@AArnott AArnott merged commit a66b644 into MessagePack-CSharp:develop Nov 11, 2024
@AArnott
Copy link
Collaborator

AArnott commented Nov 11, 2024

Oh, and in fact I fixed this bug in this repo last week, in the master branch (#2055) but it just hadn't merged forward to develop yet.

@AArnott AArnott added this to the v3.0 milestone Nov 12, 2024
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.

2 participants