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

Adjusted MsgPack004 to support records #1946

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

Merged
merged 5 commits into from
Sep 25, 2024

Conversation

N-Olbert
Copy link
Contributor

@N-Olbert N-Olbert commented Sep 4, 2024

Merging #1932 from master to develop to fix #1924 in v3.

@N-Olbert
Copy link
Contributor Author

N-Olbert commented Sep 4, 2024

@AArnott, have there been any changes or decisions regarding records with primary constructors? The second merged test flags a MsgPack007 for the record that has what I believe is a valid primary constructor. Is this intended behavior or a bug?

I annotated this in the source.

I will proceed based on your response.

{
string input = Preamble + /* lang=c#-test */ @"
[MessagePackObject]
public record {|MsgPack007:Foo|}(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AArnott : Here

Copy link
Contributor Author

@N-Olbert N-Olbert Sep 4, 2024

Choose a reason for hiding this comment

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

I think this is a false-positive for records (but a correct one for normal classes, since the semantics of a „class“- primary ctor are different)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the test as you have it here. Primary constructors for records convert parameters to properties and thus should be serialized. Primary constructors on classes do not convert their parameters to properties and thus should not be serialized. That appears to be what you're asserting here, and all the tests pass, so I'm satisfied. Thank you.

@N-Olbert
Copy link
Contributor Author

I merged the contents of the original PR. However, I believe that MsgPack007 is incorrect for records (but not for classes). If that’s the case, I can provide a fix in another PR.

@N-Olbert N-Olbert marked this pull request as ready for review September 11, 2024 18:17
@AArnott AArnott changed the title Merging #1932 Adjusted MsgPack004 to support records Sep 25, 2024
@AArnott AArnott added this to the v3.0 milestone Sep 25, 2024
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!

{
string input = Preamble + /* lang=c#-test */ @"
[MessagePackObject]
public record {|MsgPack007:Foo|}(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the test as you have it here. Primary constructors for records convert parameters to properties and thus should be serialized. Primary constructors on classes do not convert their parameters to properties and thus should not be serialized. That appears to be what you're asserting here, and all the tests pass, so I'm satisfied. Thank you.

@AArnott AArnott enabled auto-merge September 25, 2024 15:45
@AArnott AArnott disabled auto-merge September 25, 2024 16:05
@AArnott AArnott enabled auto-merge September 25, 2024 16:05
@AArnott AArnott disabled auto-merge September 25, 2024 16:05
@AArnott AArnott merged commit c7584c5 into MessagePack-CSharp:develop Sep 25, 2024
4 of 5 checks passed
AArnott added a commit that referenced this pull request Sep 25, 2024
This merge adds no content because the change in question was already brought in by #1946.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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