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

FieldMask.Merge not worked with WellKnownTypes wrappers #9283

Closed
heggi opened this issue Dec 6, 2021 · 1 comment · Fixed by #9602
Closed

FieldMask.Merge not worked with WellKnownTypes wrappers #9283

heggi opened this issue Dec 6, 2021 · 1 comment · Fixed by #9602
Labels

Comments

@heggi
Copy link

heggi commented Dec 6, 2021

What version of protobuf and what language are you using?
Version: 3.19.1
Language: C#

What operating system (Linux, Windows, ...) and version?
Any OS (Try on Ubuntu 20.04, Windows 7, 10)

What runtime / compiler are you using (e.g., python version or gcc version)
.net5.0, .net6.0

What did you do?
Example code

syntax = "proto3";

import "google/protobuf/wrappers.proto";
import "google/protobuf/field_mask.proto";

option csharp_namespace = "Test.Proto";

message MergeDataRequest {
    google.protobuf.StringValue test = 1;
}
var mask = new Google.Protobuf.WellKnownTypes.FieldMask();
mask.Paths.Add("test");

var m1 = new Test.Proto.MergeDataRequest {
    Test = "testString",
}; 

var m2 = new Test.Proto.MergeDataRequest();
mask.Merge(m1, m2);

What did you expect to see
Successful merge from source to destination.

What did you see instead?

Last line got

Unhandled exception. System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Google.Protobuf.IMessage'.
   at Google.Protobuf.FieldMaskTree.Merge(Node node, String path, IMessage source, IMessage destination, MergeOptions options) in /home/heggi/Projects/Google.Protobuf/FieldMaskTree.cs:line 336
   at Google.Protobuf.FieldMaskTree.Merge(IMessage source, IMessage destination, MergeOptions options) in /home/heggi/Projects/Google.Protobuf/FieldMaskTree.cs:line 243
   at Google.Protobuf.WellKnownTypes.FieldMask.Merge(IMessage source, IMessage destination, MergeOptions options) in /home/heggi/Projects/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs:line 324
   at Google.Protobuf.WellKnownTypes.FieldMask.Merge(IMessage source, IMessage destination) in /home/heggi/Projects/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs:line 332
   at Program.<Main>$(String[] args) in /home/heggi/Projects/test/Program.cs:line 9

Anything else we should know about your project / environment

Same trouble with any wrappers types

@boukeversteegh
Copy link
Contributor

Thanks for reporting. Same issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants