protobuf
protobuf copied to clipboard
Invalid generated C# code for the "record" class.
What version of protobuf and what language are you using? Version:
- Google.Protobuf: 3.27.1
- Protoc: 27.1
- .NET 6.0 and .NET 7.0
- Language: C#
OS: Ubuntu 22.04 (protoc), Windows 11 (Visual Studio)
What runtime / compiler are you using (e.g., python version or gcc version):
- Visual Studio 2022: 17.7.6
- MSBuild: 17.7.2
- C# Tools: 4.7.0
What did you do? Steps to reproduce the behavior:
- Generate the C# source using the command
./protoc --proto_path=../include --proto_path=central --csharp_out=out central/location.proto
- Copy the .cs file into VS (same result when copying the file, or just the contents)
- Build the project.
- See error
Compiler errors
1>------ Build started: Project: ArubaCentral.Protobuf, Configuration: Debug Any CPU ------
1>C:\Users\user\source\repos\ArubaCentral.Protobuf\Location.cs(398,7,398,13): error CS1519: Invalid token 'return' in class, record, struct, or interface member declaration
1>C:\Users\user\source\repos\ArubaCentral.Protobuf\Location.cs(398,29,398,30): error CS1031: Type expected
1>C:\Users\user\source\repos\ArubaCentral.Protobuf\Location.cs(398,29,398,30): error CS1001: Identifier expected
1>Done building project "ArubaCentral.Protobuf.csproj" -- FAILED.
Along with the following errors that Visual Studio spits out in addition to the ones above.
Error CS0535 'record' does not implement interface member 'IDeepCloneable<record>.Clone()' Location.cs - Line 352
Error CS0106 The modifier 'new' is not valid for this item Location.cs - Line 398
Error CS1520 Method must have a return type Location.cs - Line 398
Error CS0027 Keyword 'this' is not available in the current context Location.cs - Line 398