Skip to content

C# Proto2 feature : Groups - #5183

Merged
anandolee merged 11 commits into
protocolbuffers:masterfrom
ObsidianMinor:csharp/proto2-feature/groups
Nov 5, 2018
Merged

anandolee merged 11 commits into
protocolbuffers:masterfrom
ObsidianMinor:csharp/proto2-feature/groups

Conversation

@ObsidianMinor

@ObsidianMinor ObsidianMinor commented Sep 25, 2018 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

// If we actually read a tag with a field of 0, that's not a valid tag.
throw InvalidProtocolBufferException.InvalidTag();
}
if (ReachedLimit || ReachedTagLimit)

@anandolee anandolee Oct 25, 2018 •

Copy link
Copy Markdown
Contributor

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

@anandolee anandolee left a comment

Copy link
Copy Markdown
Contributor

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"

@anandolee anandolee Nov 1, 2018 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@anandolee anandolee left a comment •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@ObsidianMinor
ObsidianMinor force-pushed the csharp/proto2-feature/groups branch from 4156260 to 1f97065 Compare November 2, 2018 22:22
@ObsidianMinor

Copy link
Copy Markdown
Contributor Author

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

@anandolee

Copy link
Copy Markdown
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.

4 participants