0

Newbie in C#, I installed Rider on MacOS and installed Google.Protobuf and protobuf-net in the solution. And I find the example of C# protobuf on link, and add the files into the solution. However, when I compile the .cs files, I got those errors.

Addressbook.cs(263, 57): [CS1615] Argument 1 may not be passed with the 'ref' keyword
Addressbook.cs(445, 61): [CS1615] Argument 1 may not be passed with the 'ref' keyword
Addressbook.cs(580, 57): [CS1615] Argument 1 may not be passed with the 'ref' keyword

So how to solve these problems?

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
zmwang
  • 519
  • 1
  • 7
  • 13

2 Answers2

0

It seems like the methods argument do not accept a reference: ref argument;

To resolve this issue make sure to remove the ref before the arguments in the lines 263, 445, 580 of the Addressbook.cs file.

example given:

if (!pb::UnknownFieldSet.MergeFieldFrom(ref _unknownFields, input)) {
          return;
}

should be:

if (!pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input)) {
          return;
}
aues
  • 366
  • 2
  • 9
  • But this Addressbook.cs is created by `protoc` command, I don't think it should be modified. – zmwang Nov 08 '18 at 09:12
0

By comparing the official examples and protoc --csharp_out files, I found that the difference appears in the clause mentioned by @nnty. In the official examples, that clause is replaced by

_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);

so change all the error place with above sentence may help solve the problem.

zmwang
  • 519
  • 1
  • 7
  • 13