-
Notifications
You must be signed in to change notification settings - Fork 16k
Closed as not planned
Labels
c#inactiveDenotes the issue/PR has not seen activity in the last 90 days.Denotes the issue/PR has not seen activity in the last 90 days.
Description
What version of protobuf and what language are you using?
Versions: 3.21.1, 3.21.12, 3.22.0
Language: C#
What operating system (Linux, Windows, ...) and version?
Windows 10
What runtime / compiler are you using (e.g., python version or gcc version)
net7.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 {
map<string,int32> test = 1;
}
using Google.Protobuf.WellKnownTypes;
using System.Collections.Generic;
namespace ProtobufBug
{
internal class Program
{
private static readonly FieldMask.MergeOptions _mergeOptions = new()
{
ReplaceMessageFields = true,
ReplacePrimitiveFields = true,
ReplaceRepeatedFields = true
};
static void Main(string[] args)
{
var mask = new Google.Protobuf.WellKnownTypes.FieldMask();
mask.Paths.Add("test");
var m1 = new Test.Proto.MergeDataRequest
{
};
m1.Test.Add(new Dictionary<string, int>
{
["test"] = 1,
["test2"] = 2
});
var m2 = new Test.Proto.MergeDataRequest();
mask.Merge(m1, m2, _mergeOptions);
Console.WriteLine("Hello, World!");
}
}
}
What did you expect to see
Successful merge from source to destination.
What did you see instead?
System.InvalidCastException
HResult=0x80004002
Message=Unable to cast object of type 'Google.Protobuf.Collections.MapField`2[System.String,System.Int32]' to type 'System.Collections.IList'.
Source=Google.Protobuf
StackTrace:
at Google.Protobuf.FieldMaskTree.Merge(Node node, String path, IMessage source, IMessage destination, MergeOptions options)
at Google.Protobuf.FieldMaskTree.Merge(IMessage source, IMessage destination, MergeOptions options)
at Google.Protobuf.WellKnownTypes.FieldMask.Merge(IMessage source, IMessage destination, MergeOptions options)
at ProtobufBug.Program.Main(String[] args) in C:\develop\TempProjects\ProtobufBug\ProtobufBug\Program.cs:line 32
maaft and ahmednfwela
Metadata
Metadata
Assignees
Labels
c#inactiveDenotes the issue/PR has not seen activity in the last 90 days.Denotes the issue/PR has not seen activity in the last 90 days.