Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ linter:
rules:
- avoid_bool_literals_in_conditional_expressions
- comment_references
- prefer_relative_imports
5 changes: 5 additions & 0 deletions protobuf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
added to convert the message into the [official protocol buffers text
format][text format]. ([#1080], [#125])

* Add [well-known proto types][wkts] as libraries. This change is required for
protoc_plugin-25.0.0. ([#1081])

[text format]: https://protobuf.dev/reference/protobuf/textformat-spec/
[#1080]: https://github.com/google/protobuf.dart/pull/1080
[#125]: https://github.com/google/protobuf.dart/issues/125
[wkts]: https://protobuf.dev/reference/protobuf/google.protobuf
[#1081]: https://github.com/google/protobuf.dart/pull/1081

## 5.1.0

Expand Down
11 changes: 11 additions & 0 deletions protobuf/build_wkts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e
set -x

mkdir -p lib/well_known_types/google/protobuf

protoc \
--dart_out=lib/well_known_types \
--plugin=protoc-gen-dart=$(realpath '../protoc_plugin/bin/protoc-gen-dart-debug') \
google/protobuf/*.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ syntax = "proto3";

package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "github.com/golang/protobuf/ptypes/any";
option go_package = "google.golang.org/protobuf/types/known/anypb";
option java_package = "com.google.protobuf";
option java_outer_classname = "AnyProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";

// `Any` contains an arbitrary serialized protocol buffer message along with a
// URL that describes the type of the serialized message.
Expand All @@ -63,6 +63,10 @@ option objc_class_prefix = "GPB";
// if (any.is(Foo.class)) {
// foo = any.unpack(Foo.class);
// }
// // or ...
// if (any.isSameTypeAs(Foo.getDefaultInstance())) {
// foo = any.unpack(Foo.getDefaultInstance());
// }
//
// Example 3: Pack and unpack a message in Python.
//
Expand All @@ -77,10 +81,13 @@ option objc_class_prefix = "GPB";
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := ptypes.MarshalAny(foo)
// any, err := anypb.New(foo)
// if err != nil {
// ...
// }
// ...
// foo := &pb.Foo{}
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
// if err := any.UnmarshalTo(foo); err != nil {
// ...
// }
//
Expand All @@ -90,7 +97,6 @@ option objc_class_prefix = "GPB";
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
// name "y.z".
//
//
// JSON
// ====
// The JSON representation of an `Any` value uses the regular
Expand Down Expand Up @@ -121,7 +127,8 @@ option objc_class_prefix = "GPB";
//
message Any {
// A URL/resource name that uniquely identifies the type of the serialized
// protocol buffer message. The last segment of the URL's path must represent
// protocol buffer message. This string must contain at least
// one "/" character. The last segment of the URL's path must represent
// the fully qualified name of the type (as in
// `path/google.protobuf.Duration`). The name should be in a canonical form
// (e.g., leading "." is not accepted).
Expand All @@ -142,7 +149,8 @@ message Any {
//
// Note: this functionality is not currently available in the official
// protobuf release, and it is not used for type URLs beginning with
// type.googleapis.com.
// type.googleapis.com. As of May 2023, there are no widely used type server
// implementations and no plans to implement one.
//
// Schemes other than `http`, `https` (or the empty scheme) might be
// used with implementation specific semantics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ package google.protobuf;
import "google/protobuf/source_context.proto";
import "google/protobuf/type.proto";

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option java_package = "com.google.protobuf";
option java_outer_classname = "ApiProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option go_package = "google.golang.org/genproto/protobuf/api;api";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/apipb";

// Api is a light-weight descriptor for an API Interface.
//
Expand All @@ -51,8 +51,12 @@ option go_package = "google.golang.org/genproto/protobuf/api;api";
// sometimes simply referred to as "APIs" in other contexts, such as the name of
// this message itself. See https://cloud.google.com/apis/design/glossary for
// detailed terminology.
//
// New usages of this message as an alternative to ServiceDescriptorProto are
// strongly discouraged. This message does not reliability preserve all
// information necessary to model the schema and preserve semantics. Instead
// make use of FileDescriptorSet which preserves the necessary information.
message Api {

// The fully qualified name of this interface, including package name
// followed by the interface's simple name.
string name = 1;
Expand Down Expand Up @@ -83,7 +87,6 @@ message Api {
// be omitted. Zero major versions must only be used for
// experimental, non-GA interfaces.
//
//
string version = 4;

// Source context for the protocol buffer service represented by this
Expand All @@ -95,11 +98,18 @@ message Api {

// The source syntax of the service.
Syntax syntax = 7;

// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
string edition = 8;
}

// Method represents a method of an API interface.
//
// New usages of this message as an alternative to MethodDescriptorProto are
// strongly discouraged. This message does not reliability preserve all
// information necessary to model the schema and preserve semantics. Instead
// make use of FileDescriptorSet which preserves the necessary information.
message Method {

// The simple name of this method.
string name = 1;

Expand All @@ -119,7 +129,16 @@ message Method {
repeated Option options = 6;

// The source syntax of this method.
Syntax syntax = 7;
//
// This field should be ignored, instead the syntax should be inherited from
// Api. This is similar to Field and EnumValue.
Syntax syntax = 7 [deprecated = true];

// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
//
// This field should be ignored, instead the edition should be inherited from
// Api. This is similar to Field and EnumValue.
string edition = 8 [deprecated = true];
}

// Declares an API Interface to be included in this interface. The including
Expand Down Expand Up @@ -169,7 +188,7 @@ message Method {
// The mixin construct implies that all methods in `AccessControl` are
// also declared with same name and request/response types in
// `Storage`. A documentation generator or annotation processor will
// see the effective `Storage.GetAcl` method after inherting
// see the effective `Storage.GetAcl` method after inheriting
// documentation and annotations as follows:
//
// service Storage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ syntax = "proto3";

package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "github.com/golang/protobuf/ptypes/empty";
option go_package = "google.golang.org/protobuf/types/known/emptypb";
option java_package = "com.google.protobuf";
option java_outer_classname = "EmptyProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;

// A generic empty message that you can re-use to avoid defining duplicated
Expand All @@ -48,5 +48,4 @@ option cc_enable_arenas = true;
// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
// }
//
// The JSON representation for `Empty` is empty JSON object `{}`.
message Empty {}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ syntax = "proto3";

package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option java_package = "com.google.protobuf";
option java_outer_classname = "FieldMaskProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/fieldmaskpb";
option cc_enable_arenas = true;

// `FieldMask` represents a set of symbolic field paths, for example:
//
Expand Down Expand Up @@ -107,57 +108,49 @@ option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask";
// describe the updated values, the API ignores the values of all
// fields not covered by the mask.
//
// If a repeated field is specified for an update operation, the existing
// repeated values in the target resource will be overwritten by the new values.
// Note that a repeated field is only allowed in the last position of a `paths`
// string.
// If a repeated field is specified for an update operation, new values will
// be appended to the existing repeated field in the target resource. Note that
// a repeated field is only allowed in the last position of a `paths` string.
//
// If a sub-message is specified in the last position of the field mask for an
// update operation, then the existing sub-message in the target resource is
// overwritten. Given the target message:
// update operation, then new value will be merged into the existing sub-message
// in the target resource.
//
// For example, given the target message:
//
// f {
// b {
// d : 1
// x : 2
// d: 1
// x: 2
// }
// c : 1
// c: [1]
// }
//
// And an update message:
//
// f {
// b {
// d : 10
// d: 10
// }
// c: [2]
// }
//
// then if the field mask is:
//
// paths: "f.b"
// paths: ["f.b", "f.c"]
//
// then the result will be:
//
// f {
// b {
// d : 10
// d: 10
// x: 2
// }
// c : 1
// c: [1, 2]
// }
//
// However, if the update mask was:
//
// paths: "f.b.d"
//
// then the result would be:
//
// f {
// b {
// d : 10
// x : 2
// }
// c : 1
// }
// An implementation may provide options to override this default behavior for
// repeated and message fields.
//
// In order to reset a field's value to the default, the field must
// be in the mask and set to the default value in the provided resource.
Expand Down Expand Up @@ -245,7 +238,7 @@ option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask";
//
// The implementation of any API method which has a FieldMask type field in the
// request should verify the included field paths, and return an
// `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
// `INVALID_ARGUMENT` error if any path is unmappable.
message FieldMask {
// The set of field mask paths.
repeated string paths = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ syntax = "proto3";

package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option java_package = "com.google.protobuf";
option java_outer_classname = "SourceContextProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
option go_package = "google.golang.org/genproto/protobuf/source_context;source_context";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/sourcecontextpb";

// `SourceContext` represents information about the source of a
// protobuf element, like the file in which it is defined.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ syntax = "proto3";

package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "github.com/golang/protobuf/ptypes/struct;structpb";
option go_package = "google.golang.org/protobuf/types/known/structpb";
option java_package = "com.google.protobuf";
option java_outer_classname = "StructProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";

option csharp_namespace = "Google.Protobuf.WellKnownTypes";

// `Struct` represents a structured data value, consisting of fields
// which map to dynamically typed values. In some languages, `Struct`
Expand All @@ -56,8 +55,8 @@ message Struct {

// `Value` represents a dynamically typed value which can be either
// null, a number, a string, a boolean, a recursive struct value, or a
// list of values. A producer of value is expected to set one of that
// variants, absence of any variant indicates an error.
// list of values. A producer of value is expected to set one of these
// variants. Absence of any variant indicates an error.
//
// The JSON representation for `Value` is JSON value.
message Value {
Expand All @@ -81,7 +80,7 @@ message Value {
// `NullValue` is a singleton enumeration to represent the null value for the
// `Value` type union.
//
// The JSON representation for `NullValue` is JSON `null`.
// The JSON representation for `NullValue` is JSON `null`.
enum NullValue {
// Null value.
NULL_VALUE = 0;
Expand Down
Loading