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

C# Proto2 feature : Groups #5183

Merged

Conversation

ObsidianMinor
Copy link
Contributor

@ObsidianMinor ObsidianMinor commented Sep 25, 2018

Another day, another proto2 PR for C#.

This PR adds support for groups (including unknown field support) in the C# library and code generator.

@ObsidianMinor
Copy link
Contributor Author

I don't believe the failed ruby build is due to what I wrote, @anandolee.

uint oldTag = PushTag();
++recursionDepth;
builder.MergeFrom(this);
if (!ReachedTagLimit)
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to push and pop the expected end group tag. Can calculate the expected tag and do the compare here directly.

@@ -0,0 +1,188 @@
// Protocol Buffers - Google's data interchange format
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -383,6 +384,10 @@ public uint ReadTag()
// If we actually read a tag with a field of 0, that's not a valid tag.
throw InvalidProtocolBufferException.InvalidTag();
}
if (ReachedLimit || ReachedTagLimit)
Copy link
Contributor

@anandolee anandolee Oct 25, 2018

Choose a reason for hiding this comment

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

I understand you want to ReadTag returns 0 for the expected end group thus Merge/Parse can be stopped at the tag. However end group tag is a valid tag and returns 0 makes this function logically wrong. It will also introduce some error for example in SkipGroup():

It is easy to fix SkipGroup though but I still think ReadTag should return the valid tag. For Merge/Parse stop issue, I checked with java and it is using parseUnknownField() for decision :

" done = true;\n" // it's an endgroup tag

Copy link
Contributor

@anandolee anandolee left a comment

Choose a reason for hiding this comment

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

LGTM, just a little suggestion for better readability

"if ($has_property_check$) {\n"
" subBuilder.MergeFrom($property_name$);\n"
"}\n"
"input.ReadMessage(subBuilder);\n"
Copy link
Contributor

@anandolee anandolee Nov 1, 2018

Choose a reason for hiding this comment

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

Print the common code first and then do the type check (for better readability)

@ObsidianMinor
Copy link
Contributor Author

Fixed. I also include a fix for an issue that would prevent group end tags from being written in repeated fields.

Copy link
Contributor

@anandolee anandolee left a comment

Choose a reason for hiding this comment

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

LGTM. Wait for the tests

@ObsidianMinor
Copy link
Contributor Author

Fixed the other build files containing remnants of the separate group generators

@ObsidianMinor
Copy link
Contributor Author

I swear these build files are going to be the end of me.

@anandolee
Copy link
Contributor

No worries, it is normal to fixing the build file several times :)

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.

None yet

4 participants