-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
3.9+ C# lack of backward compatibility with extensions #6749
Comments
Spent the morning on this too. @thesoftwarejedi it should be fine if we'd only downgrade c# libs, and leave backend on 3.10, right? |
Can you provide an example of your .proto file (or a minimal repro version of it)? |
Yeah it was a mistake made when breaking up the original implementation into separate PRs (since the original implementation was made under the assumption that everything would be added in one fell swoop and different features wouldn't be left incomplete). I had opened a PR before the finale PR that made a temp fix for 3.9 and 3.10 but it never got merged so I assumed we were just going to leave it broken until 3.11 when extensions fully work. I'll write a fix today or this weekend. Proto3 extensions can only be defined for the options types in descriptor.proto @jtattermusch. syntax = "proto3";
import "google/protobuf/descriptor.proto";
extend google.protobuf.MessageOptions {
int32 a = 999999;
} Should trigger it if I'm correct. I don't think this got picked up by tests because internal access is given to the test project which means any generated extensions would compile while failing for everyone else. Plus the compatibility tests don't work so it's hard to test backwards compatibility... |
@ObsidianMinor can you come up with a fix? |
Sure @jtattermusch. I'll write it as 2 separate PRs, one will add length checks to the lib for master (so past code-gen works with updated versions of the lib) and the other will add proto2 checks to the code-gen for 3.10.x and 3.9.x if we want. |
Not sure what you mean. You're fine if the usage of the protos that have extensions has a reference >= the version of protoc used to generate them. |
The patched nuget is now available: https://www.nuget.org/packages/Google.Protobuf/3.10.1 |
@ObsidianMinor @jtattermusch - we are experiencing issues with 3.10.1 as well - what in 3.9 and 3.10 was an
If we use 3.8, everything still works. The only protos we don't generate ourselves with protoc are from |
Yeah I never confirmed this fix. Sorry that we haven't had a chance to verify this fix. Our project is not in a place to risk trying version moving around again. |
3.11 with the necessary fixes should be available very soon. |
Version: v3.10
Language: C#
OS: Windows/Linux
Runtime: .NET Core 2.1
What did you do?
Steps to reproduce the behavior:
What did you expect to see
No exception
What did you see instead?
A static initializer error reading the descriptor.
Anything else we should know about your project / environment
This comes from here:
https://github.com/protocolbuffers/protobuf/blob/master/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs#L56 where it looks like closure over
extensions
makes the poor assumption thatmessage.Proto.Extension
will have the same length.v3.9 added extensions into the generated code as seen here. However older code generated without this GeneratedClrType constructor overload fails at the static initializer reading the Descriptor as it isn't aware of the extensions.
This is also very related to #5957 which seems to indicate that this type of compatibility will be marked by an API version, referenced here.
Also opened grpc/grpc#20557 in the Grpc project to start a discussion about updating the version of protoc submoduled there.
/cc: @ObsidianMinor @jtattermusch
The text was updated successfully, but these errors were encountered: