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

Ported FieldMaskUtil from Java to C# #5045

Merged
merged 5 commits into from
Oct 8, 2018

Conversation

Falco20019
Copy link
Contributor

@Falco20019 Falco20019 commented Aug 14, 2018

Fixes #4325

I ported the functionality from Java to C#. Still a bit unsure if we should keep the classes seperate as Utils or just merging it all into FieldMaskTreePartial (would be getting a huge class...). All other Utils from Java have been ported into the *Partial classes, but those were mainly static classes anyway. The FieldMaskUtil has a complete FieldMaskTree helper class.

Right now, this would allow for easy portability by keeping the Util but also fit with the other classes by creating static helpers in Partial. Any preferences?

@anandolee offered in #4325 to do the PR

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Aug 14, 2018

Thanks for putting this together! Note that we are not so happy about the name "FieldMaskUtil" in Java and have a plan to rename it to "FieldMasks". I would recommend against using the name "FieldMaksUtil" in C# just because Java did.

@Falco20019
Copy link
Contributor Author

@xfxyjwf Thanks for the feedback. Would you prefer to include the FieldMaskTree in FieldMaskPartial (separate partial class), or maybe putting it in the root like JsonFormatter and other helper classes? I think it may be better to only have the stuff directly in FieldMasks and dropping the FieldMaskUtil class completely.

@anandolee
Copy link
Contributor

Can we remove FieldMaskUtil. I noticed FieldMaskPartial has most APIs except IsValid. FieldMaskPartial and FieldMaskUtil are kind of duplicated

@Falco20019
Copy link
Contributor Author

I plan to do so, was just waiting on a response to my question. Would you prefer having the FieldMaskTree in a partial or as separate class in root like JsonFormatter?

@Falco20019
Copy link
Contributor Author

@anandolee @xfxyjwf Still waiting for feedback on your preference how to separate FieldMaskTree. Either adding it to FieldMaskPartial which would blow it up a bit, or putting it into root like done with JsonFormatter but cluttering up the space there while it's only used by FieldMaskTree and completely internal?

Both are valid ways to proceed with their own up- and downsides. I would prefer the root JsonFormatter-like aproach.

@anandolee
Copy link
Contributor

I'd prefer to make FieldMaskTree in a separated file instead of blow FieldMaskPartial up. And yes FieldMaskTree should be internal.

- Removed FieldMaskUtil
- Moved FieldMaskTree to root
- Updated tests
@Falco20019
Copy link
Contributor Author

Thanks for the feedback. Just applied the changes.

- Removed internal method FieldMaskTree.GetFieldPaths
- Proof FieldMask.Paths only contains expected values
@Falco20019
Copy link
Contributor Author

As a short summary:
I prefer Contains and checking the Count over ToString to avoid making assumptions on sorting and have it future proof. Also added assertions to proof specific members are not part of the created path list.

Due to the removal of FieldMaskTree.GetFieldPaths, FieldMaskTreeTest is now having asumptions based on FieldMask and FieldMaskTree.ToFieldMask.

@anandolee
Copy link
Contributor

Thanks for the change. It looks good to me, just wait the tests green

@anandolee
Copy link
Contributor

Oh for the newly added FieldMaskTreeTest.cs, you need to update Makefile.am to pass distcheck test:
https://github.com/protocolbuffers/protobuf/blob/master/Makefile.am

@Falco20019
Copy link
Contributor Author

@anandolee I hope the distcheck works now :)

@anandolee
Copy link
Contributor

csharp/src/Google.Protobuf/FieldMaskTree.cs is also newly added and need to be in Makefile.am

@Falco20019
Copy link
Contributor Author

Ok, commited. Is it only giving one error a time? This should be all of the newly added files. If there is anything else to check, just let me know :) (Currently I'm in the same timezone as you which should speed stuff up a bit).

@anandolee anandolee merged commit 80e530d into protocolbuffers:master Oct 8, 2018
@Falco20019 Falco20019 deleted the add-fieldmaskutil branch October 9, 2018 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants