From 18e0a2e5ec883d665a4e8fe57a1eb3e603340de7 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 1 Oct 2015 10:38:01 +0100 Subject: Generated code from previous commit. --- csharp/src/Google.Protobuf/WellKnownTypes/Any.cs | 50 +++++ csharp/src/Google.Protobuf/WellKnownTypes/Api.cs | 154 ++++++++++++++++ .../src/Google.Protobuf/WellKnownTypes/Duration.cs | 48 +++++ csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs | 9 + .../Google.Protobuf/WellKnownTypes/FieldMask.cs | 101 +++++++++++ .../WellKnownTypes/SourceContext.cs | 9 + .../src/Google.Protobuf/WellKnownTypes/Struct.cs | 60 ++++++ .../Google.Protobuf/WellKnownTypes/Timestamp.cs | 54 ++++++ csharp/src/Google.Protobuf/WellKnownTypes/Type.cs | 201 +++++++++++++++++++++ .../src/Google.Protobuf/WellKnownTypes/Wrappers.cs | 72 ++++++++ 10 files changed, 758 insertions(+) (limited to 'csharp/src/Google.Protobuf/WellKnownTypes') diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs index 6bcdfdef..4a704018 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs @@ -40,6 +40,33 @@ namespace Google.Protobuf.WellKnownTypes { } } #region Messages + /// + /// `Any` contains an arbitrary serialized message along with a URL + /// that describes the type of the serialized message. + /// JSON + /// ==== + /// The JSON representation of an `Any` value uses the regular + /// representation of the deserialized, embedded message, with an + /// additional field `@type` which contains the type URL. Example: + /// package google.profile; + /// message Person { + /// string first_name = 1; + /// string last_name = 2; + /// } + /// { + /// "@type": "type.googleapis.com/google.profile.Person", + /// "firstName": <string>, + /// "lastName": <string> + /// } + /// If the embedded message type is well-known and has a custom JSON + /// representation, that representation will be embedded adding a field + /// `value` which holds the custom JSON in addition to the the `@type` + /// field. Example (for message [google.protobuf.Duration][google.protobuf.Duration]): + /// { + /// "@type": "type.googleapis.com/google.protobuf.Duration", + /// "value": "1.212s" + /// } + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Any : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Any()); @@ -68,8 +95,27 @@ namespace Google.Protobuf.WellKnownTypes { return new Any(this); } + /// Field number for the "type_url" field. public const int TypeUrlFieldNumber = 1; private string typeUrl_ = ""; + /// + /// A URL/resource name whose content describes the type of the + /// serialized message. + /// For URLs which use the schema `http`, `https`, or no schema, the + /// following restrictions and interpretations apply: + /// * If no schema is provided, `https` is assumed. + /// * The last segment of the URL's path must represent the fully + /// qualified name of the type (as in `path/google.protobuf.Duration`). + /// * An HTTP GET on the URL must yield a [google.protobuf.Type][google.protobuf.Type] + /// value in binary format, or produce an error. + /// * Applications are allowed to cache lookup results based on the + /// URL, or have them precompiled into a binary to avoid any + /// lookup. Therefore, binary compatibility needs to be preserved + /// on changes to types. (Use versioned type names to manage + /// breaking changes.) + /// Schemas other than `http`, `https` (or the empty schema) might be + /// used with implementation specific semantics. + /// public string TypeUrl { get { return typeUrl_; } set { @@ -77,8 +123,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "value" field. public const int ValueFieldNumber = 2; private pb::ByteString value_ = pb::ByteString.Empty; + /// + /// Must be valid serialized data of the above specified type. + /// public pb::ByteString Value { get { return value_; } set { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs index f2166ca5..2c64314d 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs @@ -54,6 +54,9 @@ namespace Google.Protobuf.WellKnownTypes { } } #region Messages + /// + /// Api is a light-weight descriptor for a protocol buffer service. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Api : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Api()); @@ -87,8 +90,13 @@ namespace Google.Protobuf.WellKnownTypes { return new Api(this); } + /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + /// + /// The fully qualified name of this api, including package name + /// followed by the api's simple name. + /// public string Name { get { return name_; } set { @@ -96,24 +104,53 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "methods" field. public const int MethodsFieldNumber = 2; private static readonly pb::FieldCodec _repeated_methods_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Method.Parser); private readonly pbc::RepeatedField methods_ = new pbc::RepeatedField(); + /// + /// The methods of this api, in unspecified order. + /// public pbc::RepeatedField Methods { get { return methods_; } } + /// Field number for the "options" field. public const int OptionsFieldNumber = 3; private static readonly pb::FieldCodec _repeated_options_codec = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + /// + /// Any metadata attached to the API. + /// public pbc::RepeatedField Options { get { return options_; } } + /// Field number for the "version" field. public const int VersionFieldNumber = 4; private string version_ = ""; + /// + /// A version string for this api. If specified, must have the form + /// `major-version.minor-version`, as in `1.10`. If the minor version + /// is omitted, it defaults to zero. If the entire version field is + /// empty, the major version is derived from the package name, as + /// outlined below. If the field is not empty, the version in the + /// package name will be verified to be consistent with what is + /// provided here. + /// The versioning schema uses [semantic + /// versioning](http://semver.org) where the major version number + /// indicates a breaking change and the minor version an additive, + /// non-breaking change. Both version numbers are signals to users + /// what to expect from different versions, and should be carefully + /// chosen based on the product plan. + /// The major version is also reflected in the package name of the + /// API, which must end in `v<major-version>`, as in + /// `google.feature.v1`. For major versions 0 and 1, the suffix can + /// be omitted. Zero major versions must only be used for + /// experimental, none-GA apis. + /// public string Version { get { return version_; } set { @@ -121,8 +158,13 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "source_context" field. public const int SourceContextFieldNumber = 5; private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; + /// + /// Source context for the protocol buffer service represented by this + /// message. + /// public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { get { return sourceContext_; } set { @@ -130,16 +172,24 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "mixins" field. public const int MixinsFieldNumber = 6; private static readonly pb::FieldCodec _repeated_mixins_codec = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.WellKnownTypes.Mixin.Parser); private readonly pbc::RepeatedField mixins_ = new pbc::RepeatedField(); + /// + /// Included APIs. See [Mixin][]. + /// public pbc::RepeatedField Mixins { get { return mixins_; } } + /// Field number for the "syntax" field. public const int SyntaxFieldNumber = 7; private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2; + /// + /// The source syntax of the service. + /// public global::Google.Protobuf.WellKnownTypes.Syntax Syntax { get { return syntax_; } set { @@ -294,6 +344,9 @@ namespace Google.Protobuf.WellKnownTypes { } + /// + /// Method represents a method of an api. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Method : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Method()); @@ -327,8 +380,12 @@ namespace Google.Protobuf.WellKnownTypes { return new Method(this); } + /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + /// + /// The simple name of this method. + /// public string Name { get { return name_; } set { @@ -336,8 +393,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "request_type_url" field. public const int RequestTypeUrlFieldNumber = 2; private string requestTypeUrl_ = ""; + /// + /// A URL of the input message type. + /// public string RequestTypeUrl { get { return requestTypeUrl_; } set { @@ -345,8 +406,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "request_streaming" field. public const int RequestStreamingFieldNumber = 3; private bool requestStreaming_; + /// + /// If true, the request is streamed. + /// public bool RequestStreaming { get { return requestStreaming_; } set { @@ -354,8 +419,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "response_type_url" field. public const int ResponseTypeUrlFieldNumber = 4; private string responseTypeUrl_ = ""; + /// + /// The URL of the output message type. + /// public string ResponseTypeUrl { get { return responseTypeUrl_; } set { @@ -363,8 +432,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "response_streaming" field. public const int ResponseStreamingFieldNumber = 5; private bool responseStreaming_; + /// + /// If true, the response is streamed. + /// public bool ResponseStreaming { get { return responseStreaming_; } set { @@ -372,16 +445,24 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "options" field. public const int OptionsFieldNumber = 6; private static readonly pb::FieldCodec _repeated_options_codec = pb::FieldCodec.ForMessage(50, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + /// + /// Any metadata attached to the method. + /// public pbc::RepeatedField Options { get { return options_; } } + /// Field number for the "syntax" field. public const int SyntaxFieldNumber = 7; private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2; + /// + /// The source syntax of this method. + /// public global::Google.Protobuf.WellKnownTypes.Syntax Syntax { get { return syntax_; } set { @@ -544,6 +625,70 @@ namespace Google.Protobuf.WellKnownTypes { } + /// + /// Declares an API to be included in this API. The including API must + /// redeclare all the methods from the included API, but documentation + /// and options are inherited as follows: + /// - If after comment and whitespace stripping, the documentation + /// string of the redeclared method is empty, it will be inherited + /// from the original method. + /// - Each annotation belonging to the service config (http, + /// visibility) which is not set in the redeclared method will be + /// inherited. + /// - If an http annotation is inherited, the path pattern will be + /// modified as follows. Any version prefix will be replaced by the + /// version of the including API plus the [root][] path if specified. + /// Example of a simple mixin: + /// package google.acl.v1; + /// service AccessControl { + /// // Get the underlying ACL object. + /// rpc GetAcl(GetAclRequest) returns (Acl) { + /// option (google.api.http).get = "/v1/{resource=**}:getAcl"; + /// } + /// } + /// package google.storage.v2; + /// service Storage { + /// // (-- see AccessControl.GetAcl --) + /// rpc GetAcl(GetAclRequest) returns (Acl); + /// // Get a data record. + /// rpc GetData(GetDataRequest) returns (Data) { + /// option (google.api.http).get = "/v2/{resource=**}"; + /// } + /// } + /// Example of a mixin configuration: + /// apis: + /// - name: google.storage.v2.Storage + /// mixins: + /// - name: google.acl.v1.AccessControl + /// 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 + /// documentation and annotations as follows: + /// service Storage { + /// // Get the underlying ACL object. + /// rpc GetAcl(GetAclRequest) returns (Acl) { + /// option (google.api.http).get = "/v2/{resource=**}:getAcl"; + /// } + /// ... + /// } + /// Note how the version in the path pattern changed from `v1` to `v2`. + /// If the `root` field in the mixin is specified, it should be a + /// relative path under which inherited HTTP paths are placed. Example: + /// apis: + /// - name: google.storage.v2.Storage + /// mixins: + /// - name: google.acl.v1.AccessControl + /// root: acls + /// This implies the following inherited HTTP annotation: + /// service Storage { + /// // Get the underlying ACL object. + /// rpc GetAcl(GetAclRequest) returns (Acl) { + /// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; + /// } + /// ... + /// } + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Mixin : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Mixin()); @@ -572,8 +717,12 @@ namespace Google.Protobuf.WellKnownTypes { return new Mixin(this); } + /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + /// + /// The fully qualified name of the API which is included. + /// public string Name { get { return name_; } set { @@ -581,8 +730,13 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "root" field. public const int RootFieldNumber = 2; private string root_ = ""; + /// + /// If non-empty specifies a path under which inherited HTTP paths + /// are rooted. + /// public string Root { get { return root_; } set { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs index e671eac8..39251e2e 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs @@ -41,6 +41,40 @@ namespace Google.Protobuf.WellKnownTypes { } } #region Messages + /// + /// A Duration represents a signed, fixed-length span of time represented + /// as a count of seconds and fractions of seconds at nanosecond + /// resolution. It is independent of any calendar and concepts like "day" + /// or "month". It is related to Timestamp in that the difference between + /// two Timestamp values is a Duration and it can be added or subtracted + /// from a Timestamp. Range is approximately +-10,000 years. + /// Example 1: Compute Duration from two Timestamps in pseudo code. + /// Timestamp start = ...; + /// Timestamp end = ...; + /// Duration duration = ...; + /// duration.seconds = end.seconds - start.seconds; + /// duration.nanos = end.nanos - start.nanos; + /// if (duration.seconds < 0 && duration.nanos > 0) { + /// duration.seconds += 1; + /// duration.nanos -= 1000000000; + /// } else if (durations.seconds > 0 && duration.nanos < 0) { + /// duration.seconds -= 1; + /// duration.nanos += 1000000000; + /// } + /// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + /// Timestamp start = ...; + /// Duration duration = ...; + /// Timestamp end = ...; + /// end.seconds = start.seconds + duration.seconds; + /// end.nanos = start.nanos + duration.nanos; + /// if (end.nanos < 0) { + /// end.seconds -= 1; + /// end.nanos += 1000000000; + /// } else if (end.nanos >= 1000000000) { + /// end.seconds += 1; + /// end.nanos -= 1000000000; + /// } + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Duration : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Duration()); @@ -69,8 +103,13 @@ namespace Google.Protobuf.WellKnownTypes { return new Duration(this); } + /// Field number for the "seconds" field. public const int SecondsFieldNumber = 1; private long seconds_; + /// + /// Signed seconds of the span of time. Must be from -315,576,000,000 + /// to +315,576,000,000 inclusive. + /// public long Seconds { get { return seconds_; } set { @@ -78,8 +117,17 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "nanos" field. public const int NanosFieldNumber = 2; private int nanos_; + /// + /// Signed fractions of a second at nanosecond resolution of the span + /// of time. Durations less than one second are represented with a 0 + /// `seconds` field and a positive or negative `nanos` field. For durations + /// of one second or more, a non-zero value for the `nanos` field must be + /// of the same sign as the `seconds` field. Must be from -999,999,999 + /// to +999,999,999 inclusive. + /// public int Nanos { get { return nanos_; } set { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs index 050f7476..18223a9e 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs @@ -40,6 +40,15 @@ namespace Google.Protobuf.WellKnownTypes { } } #region Messages + /// + /// A generic empty message that you can re-use to avoid defining duplicated + /// empty messages in your APIs. A typical example is to use it as the request + /// or the response type of an API method. For instance: + /// service Foo { + /// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); + /// } + /// The JSON representation for `Empty` is empty JSON object `{}`. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Empty : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Empty()); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs index 14acf394..33c814ef 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs @@ -40,6 +40,103 @@ namespace Google.Protobuf.WellKnownTypes { } } #region Messages + /// + /// `FieldMask` represents a set of symbolic field paths, for example: + /// paths: "f.a" + /// paths: "f.b.d" + /// Here `f` represents a field in some root message, `a` and `b` + /// fields in the message found in `f`, and `d` a field found in the + /// message in `f.b`. + /// Field masks are used to specify a subset of fields that should be + /// returned by a get operation or modified by an update operation. + /// Field masks also have a custom JSON encoding (see below). + /// # Field Masks in Projections + /// When used in the context of a projection, a response message or + /// sub-message is filtered by the API to only contain those fields as + /// specified in the mask. For example, if the mask in the previous + /// example is applied to a response message as follows: + /// f { + /// a : 22 + /// b { + /// d : 1 + /// x : 2 + /// } + /// y : 13 + /// } + /// z: 8 + /// The result will not contain specific values for fields x,y and z + /// (there value will be set to the default, and omitted in proto text + /// output): + /// f { + /// a : 22 + /// b { + /// d : 1 + /// } + /// } + /// A repeated field is not allowed except at the last position of a + /// field mask. + /// If a FieldMask object is not present in a get operation, the + /// operation applies to all fields (as if a FieldMask of all fields + /// had been specified). + /// Note that a field mask does not necessarily applies to the + /// top-level response message. In case of a REST get operation, the + /// field mask applies directly to the response, but in case of a REST + /// list operation, the mask instead applies to each individual message + /// in the returned resource list. In case of a REST custom method, + /// other definitions may be used. Where the mask applies will be + /// clearly documented together with its declaration in the API. In + /// any case, the effect on the returned resource/resources is required + /// behavior for APIs. + /// # Field Masks in Update Operations + /// A field mask in update operations specifies which fields of the + /// targeted resource are going to be updated. The API is required + /// to only change the values of the fields as specified in the mask + /// and leave the others untouched. If a resource is passed in to + /// describe the updated values, the API ignores the values of all + /// fields not covered by the mask. + /// 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. + /// Hence, in order to reset all fields of a resource, provide a default + /// instance of the resource and set all fields in the mask, or do + /// not provide a mask as described below. + /// If a field mask is not present on update, the operation applies to + /// all fields (as if a field mask of all fields has been specified). + /// Note that in the presence of schema evolution, this may mean that + /// fields the client does not know and has therefore not filled into + /// the request will be reset to their default. If this is unwanted + /// behavior, a specific service may require a client to always specify + /// a field mask, producing an error if not. + /// As with get operations, the location of the resource which + /// describes the updated values in the request message depends on the + /// operation kind. In any case, the effect of the field mask is + /// required to be honored by the API. + /// ## Considerations for HTTP REST + /// The HTTP kind of an update operation which uses a field mask must + /// be set to PATCH instead of PUT in order to satisfy HTTP semantics + /// (PUT must only be used for full updates). + /// # JSON Encoding of Field Masks + /// In JSON, a field mask is encoded as a single string where paths are + /// separated by a comma. Fields name in each path are converted + /// to/from lower-camel naming conventions. + /// As an example, consider the following message declarations: + /// message Profile { + /// User user = 1; + /// Photo photo = 2; + /// } + /// message User { + /// string display_name = 1; + /// string address = 2; + /// } + /// In proto a field mask for `Profile` may look as such: + /// mask { + /// paths: "user.display_name" + /// paths: "photo" + /// } + /// In JSON, the same mask is represented as below: + /// { + /// mask: "user.displayName,photo" + /// } + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class FieldMask : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FieldMask()); @@ -67,10 +164,14 @@ namespace Google.Protobuf.WellKnownTypes { return new FieldMask(this); } + /// Field number for the "paths" field. public const int PathsFieldNumber = 1; private static readonly pb::FieldCodec _repeated_paths_codec = pb::FieldCodec.ForString(10); private readonly pbc::RepeatedField paths_ = new pbc::RepeatedField(); + /// + /// The set of field mask paths. + /// public pbc::RepeatedField Paths { get { return paths_; } } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs index e4d063b0..d87c54bd 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs @@ -41,6 +41,10 @@ namespace Google.Protobuf.WellKnownTypes { } } #region Messages + /// + /// `SourceContext` represents information about the source of a + /// protobuf element, like the file in which it is defined. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class SourceContext : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SourceContext()); @@ -68,8 +72,13 @@ namespace Google.Protobuf.WellKnownTypes { return new SourceContext(this); } + /// Field number for the "file_name" field. public const int FileNameFieldNumber = 1; private string fileName_ = ""; + /// + /// The path-qualified name of the .proto file that contained the associated + /// protobuf element. For example: `"google/protobuf/source.proto"`. + /// public string FileName { get { return fileName_; } set { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs index 257d52d8..a9961bea 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs @@ -52,13 +52,30 @@ namespace Google.Protobuf.WellKnownTypes { } } #region Enums + /// + /// `NullValue` is a singleton enumeration to represent the null value for the + /// `Value` type union. + /// The JSON representation for `NullValue` is JSON `null`. + /// public enum NullValue { + /// + /// Null value. + /// NULL_VALUE = 0, } #endregion #region Messages + /// + /// `Struct` represents a structured data value, consisting of fields + /// which map to dynamically typed values. In some languages, `Struct` + /// might be supported by a native representation. For example, in + /// scripting languages like JS a struct is represented as an + /// object. The details of that representation are described together + /// with the proto support for the language. + /// The JSON representation for `Struct` is JSON object. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Struct : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Struct()); @@ -86,10 +103,14 @@ namespace Google.Protobuf.WellKnownTypes { return new Struct(this); } + /// Field number for the "fields" field. public const int FieldsFieldNumber = 1; private static readonly pbc::MapField.Codec _map_fields_codec = new pbc::MapField.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Value.Parser), 10); private readonly pbc::MapField fields_ = new pbc::MapField(); + /// + /// Map of dynamically typed values. + /// public pbc::MapField Fields { get { return fields_; } } @@ -153,6 +174,13 @@ namespace Google.Protobuf.WellKnownTypes { } + /// + /// `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. + /// The JSON representation for `Value` is JSON value. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Value : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Value()); @@ -200,7 +228,11 @@ namespace Google.Protobuf.WellKnownTypes { return new Value(this); } + /// Field number for the "null_value" field. public const int NullValueFieldNumber = 1; + /// + /// Represents a null value. + /// public global::Google.Protobuf.WellKnownTypes.NullValue NullValue { get { return kindCase_ == KindOneofCase.NullValue ? (global::Google.Protobuf.WellKnownTypes.NullValue) kind_ : global::Google.Protobuf.WellKnownTypes.NullValue.NULL_VALUE; } set { @@ -209,7 +241,11 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "number_value" field. public const int NumberValueFieldNumber = 2; + /// + /// Represents a double value. + /// public double NumberValue { get { return kindCase_ == KindOneofCase.NumberValue ? (double) kind_ : 0D; } set { @@ -218,7 +254,11 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "string_value" field. public const int StringValueFieldNumber = 3; + /// + /// Represents a string value. + /// public string StringValue { get { return kindCase_ == KindOneofCase.StringValue ? (string) kind_ : ""; } set { @@ -227,7 +267,11 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "bool_value" field. public const int BoolValueFieldNumber = 4; + /// + /// Represents a boolean value. + /// public bool BoolValue { get { return kindCase_ == KindOneofCase.BoolValue ? (bool) kind_ : false; } set { @@ -236,7 +280,11 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "struct_value" field. public const int StructValueFieldNumber = 5; + /// + /// Represents a structured value. + /// public global::Google.Protobuf.WellKnownTypes.Struct StructValue { get { return kindCase_ == KindOneofCase.StructValue ? (global::Google.Protobuf.WellKnownTypes.Struct) kind_ : null; } set { @@ -245,7 +293,11 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "list_value" field. public const int ListValueFieldNumber = 6; + /// + /// Represents a repeated `Value`. + /// public global::Google.Protobuf.WellKnownTypes.ListValue ListValue { get { return kindCase_ == KindOneofCase.ListValue ? (global::Google.Protobuf.WellKnownTypes.ListValue) kind_ : null; } set { @@ -435,6 +487,10 @@ namespace Google.Protobuf.WellKnownTypes { } + /// + /// `ListValue` is a wrapper around a repeated field of values. + /// The JSON representation for `ListValue` is JSON array. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class ListValue : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ListValue()); @@ -462,10 +518,14 @@ namespace Google.Protobuf.WellKnownTypes { return new ListValue(this); } + /// Field number for the "values" field. public const int ValuesFieldNumber = 1; private static readonly pb::FieldCodec _repeated_values_codec = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.WellKnownTypes.Value.Parser); private readonly pbc::RepeatedField values_ = new pbc::RepeatedField(); + /// + /// Repeated field of dynamically typed values. + /// public pbc::RepeatedField Values { get { return values_; } } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs index 6b186b37..f372f8fd 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs @@ -41,6 +41,47 @@ namespace Google.Protobuf.WellKnownTypes { } } #region Messages + /// + /// A Timestamp represents a point in time independent of any time zone + /// or calendar, represented as seconds and fractions of seconds at + /// nanosecond resolution in UTC Epoch time. It is encoded using the + /// Proleptic Gregorian Calendar which extends the Gregorian calendar + /// backwards to year one. It is encoded assuming all minutes are 60 + /// seconds long, i.e. leap seconds are "smeared" so that no leap second + /// table is needed for interpretation. Range is from + /// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. + /// By restricting to that range, we ensure that we can convert to + /// and from RFC 3339 date strings. + /// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). + /// Example 1: Compute Timestamp from POSIX `time()`. + /// Timestamp timestamp; + /// timestamp.set_seconds(time(NULL)); + /// timestamp.set_nanos(0); + /// Example 2: Compute Timestamp from POSIX `gettimeofday()`. + /// struct timeval tv; + /// gettimeofday(&tv, NULL); + /// Timestamp timestamp; + /// timestamp.set_seconds(tv.tv_sec); + /// timestamp.set_nanos(tv.tv_usec * 1000); + /// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + /// FILETIME ft; + /// GetSystemTimeAsFileTime(&ft); + /// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + /// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + /// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + /// Timestamp timestamp; + /// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + /// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + /// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + /// long millis = System.currentTimeMillis(); + /// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + /// .setNanos((int) ((millis % 1000) * 1000000)).build(); + /// Example 5: Compute Timestamp from current time in Python. + /// now = time.time() + /// seconds = int(now) + /// nanos = int((now - seconds) * 10**9) + /// timestamp = Timestamp(seconds=seconds, nanos=nanos) + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Timestamp : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Timestamp()); @@ -69,8 +110,14 @@ namespace Google.Protobuf.WellKnownTypes { return new Timestamp(this); } + /// Field number for the "seconds" field. public const int SecondsFieldNumber = 1; private long seconds_; + /// + /// Represents seconds of UTC time since Unix epoch + /// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to + /// 9999-12-31T23:59:59Z inclusive. + /// public long Seconds { get { return seconds_; } set { @@ -78,8 +125,15 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "nanos" field. public const int NanosFieldNumber = 2; private int nanos_; + /// + /// Non-negative fractions of a second at nanosecond resolution. Negative + /// second values with fractions must still have non-negative nanos values + /// that count forward in time. Must be from 0 to 999,999,999 + /// inclusive. + /// public int Nanos { get { return nanos_; } set { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs index 48039d66..3be90853 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs @@ -74,14 +74,26 @@ namespace Google.Protobuf.WellKnownTypes { } } #region Enums + /// + /// Syntax specifies the syntax in which a service element was defined. + /// public enum Syntax { + /// + /// Syntax "proto2" + /// SYNTAX_PROTO2 = 0, + /// + /// Syntax "proto3" + /// SYNTAX_PROTO3 = 1, } #endregion #region Messages + /// + /// A light-weight descriptor for a proto message type. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Type : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Type()); @@ -114,8 +126,12 @@ namespace Google.Protobuf.WellKnownTypes { return new Type(this); } + /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + /// + /// The fully qualified message name. + /// public string Name { get { return name_; } set { @@ -123,32 +139,48 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "fields" field. public const int FieldsFieldNumber = 2; private static readonly pb::FieldCodec _repeated_fields_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Field.Parser); private readonly pbc::RepeatedField fields_ = new pbc::RepeatedField(); + /// + /// The list of fields. + /// public pbc::RepeatedField Fields { get { return fields_; } } + /// Field number for the "oneofs" field. public const int OneofsFieldNumber = 3; private static readonly pb::FieldCodec _repeated_oneofs_codec = pb::FieldCodec.ForString(26); private readonly pbc::RepeatedField oneofs_ = new pbc::RepeatedField(); + /// + /// The list of oneof definitions. + /// public pbc::RepeatedField Oneofs { get { return oneofs_; } } + /// Field number for the "options" field. public const int OptionsFieldNumber = 4; private static readonly pb::FieldCodec _repeated_options_codec = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + /// + /// The proto options. + /// public pbc::RepeatedField Options { get { return options_; } } + /// Field number for the "source_context" field. public const int SourceContextFieldNumber = 5; private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; + /// + /// The source context. + /// public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { get { return sourceContext_; } set { @@ -156,8 +188,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "syntax" field. public const int SyntaxFieldNumber = 6; private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2; + /// + /// The source syntax. + /// public global::Google.Protobuf.WellKnownTypes.Syntax Syntax { get { return syntax_; } set { @@ -296,6 +332,9 @@ namespace Google.Protobuf.WellKnownTypes { } + /// + /// Field represents a single field of a message type. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Field : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Field()); @@ -331,8 +370,12 @@ namespace Google.Protobuf.WellKnownTypes { return new Field(this); } + /// Field number for the "kind" field. public const int KindFieldNumber = 1; private global::Google.Protobuf.WellKnownTypes.Field.Types.Kind kind_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN; + /// + /// The field kind. + /// public global::Google.Protobuf.WellKnownTypes.Field.Types.Kind Kind { get { return kind_; } set { @@ -340,8 +383,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "cardinality" field. public const int CardinalityFieldNumber = 2; private global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality cardinality_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN; + /// + /// The field cardinality, i.e. optional/required/repeated. + /// public global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality Cardinality { get { return cardinality_; } set { @@ -349,8 +396,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "number" field. public const int NumberFieldNumber = 3; private int number_; + /// + /// The proto field number. + /// public int Number { get { return number_; } set { @@ -358,8 +409,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "name" field. public const int NameFieldNumber = 4; private string name_ = ""; + /// + /// The field name. + /// public string Name { get { return name_; } set { @@ -367,8 +422,13 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "type_url" field. public const int TypeUrlFieldNumber = 6; private string typeUrl_ = ""; + /// + /// The type URL (without the scheme) when the type is MESSAGE or ENUM, + /// such as `type.googleapis.com/google.protobuf.Empty`. + /// public string TypeUrl { get { return typeUrl_; } set { @@ -376,8 +436,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "oneof_index" field. public const int OneofIndexFieldNumber = 7; private int oneofIndex_; + /// + /// Index in Type.oneofs. Starts at 1. Zero means no oneof mapping. + /// public int OneofIndex { get { return oneofIndex_; } set { @@ -385,8 +449,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "packed" field. public const int PackedFieldNumber = 8; private bool packed_; + /// + /// Whether to use alternative packed wire representation. + /// public bool Packed { get { return packed_; } set { @@ -394,16 +462,24 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "options" field. public const int OptionsFieldNumber = 9; private static readonly pb::FieldCodec _repeated_options_codec = pb::FieldCodec.ForMessage(74, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + /// + /// The proto options. + /// public pbc::RepeatedField Options { get { return options_; } } + /// Field number for the "json_name" field. public const int JsonNameFieldNumber = 10; private string jsonName_ = ""; + /// + /// The JSON name for this field. + /// public string JsonName { get { return jsonName_; } set { @@ -600,32 +676,108 @@ namespace Google.Protobuf.WellKnownTypes { /// Container for nested types declared in the Field message type. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class Types { + /// + /// Kind represents a basic field type. + /// public enum Kind { + /// + /// Field type unknown. + /// TYPE_UNKNOWN = 0, + /// + /// Field type double. + /// TYPE_DOUBLE = 1, + /// + /// Field type float. + /// TYPE_FLOAT = 2, + /// + /// Field type int64. + /// TYPE_INT64 = 3, + /// + /// Field type uint64. + /// TYPE_UINT64 = 4, + /// + /// Field type int32. + /// TYPE_INT32 = 5, + /// + /// Field type fixed64. + /// TYPE_FIXED64 = 6, + /// + /// Field type fixed32. + /// TYPE_FIXED32 = 7, + /// + /// Field type bool. + /// TYPE_BOOL = 8, + /// + /// Field type string. + /// TYPE_STRING = 9, + /// + /// Field type group (deprecated proto2 type) + /// TYPE_GROUP = 10, + /// + /// Field type message. + /// TYPE_MESSAGE = 11, + /// + /// Field type bytes. + /// TYPE_BYTES = 12, + /// + /// Field type uint32. + /// TYPE_UINT32 = 13, + /// + /// Field type enum. + /// TYPE_ENUM = 14, + /// + /// Field type sfixed32. + /// TYPE_SFIXED32 = 15, + /// + /// Field type sfixed64. + /// TYPE_SFIXED64 = 16, + /// + /// Field type sint32. + /// TYPE_SINT32 = 17, + /// + /// Field type sint64. + /// TYPE_SINT64 = 18, } + /// + /// Cardinality represents whether a field is optional, required, or + /// repeated. + /// public enum Cardinality { + /// + /// The field cardinality is unknown. Typically an error condition. + /// CARDINALITY_UNKNOWN = 0, + /// + /// For optional fields. + /// CARDINALITY_OPTIONAL = 1, + /// + /// For required fields. Not used for proto3. + /// CARDINALITY_REQUIRED = 2, + /// + /// For repeated fields. + /// CARDINALITY_REPEATED = 3, } @@ -634,6 +786,9 @@ namespace Google.Protobuf.WellKnownTypes { } + /// + /// Enum type definition. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Enum : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Enum()); @@ -665,8 +820,12 @@ namespace Google.Protobuf.WellKnownTypes { return new Enum(this); } + /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + /// + /// Enum type name. + /// public string Name { get { return name_; } set { @@ -674,24 +833,36 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "enumvalue" field. public const int EnumvalueFieldNumber = 2; private static readonly pb::FieldCodec _repeated_enumvalue_codec = pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.EnumValue.Parser); private readonly pbc::RepeatedField enumvalue_ = new pbc::RepeatedField(); + /// + /// Enum value definitions. + /// public pbc::RepeatedField Enumvalue { get { return enumvalue_; } } + /// Field number for the "options" field. public const int OptionsFieldNumber = 3; private static readonly pb::FieldCodec _repeated_options_codec = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + /// + /// Proto options for the enum type. + /// public pbc::RepeatedField Options { get { return options_; } } + /// Field number for the "source_context" field. public const int SourceContextFieldNumber = 4; private global::Google.Protobuf.WellKnownTypes.SourceContext sourceContext_; + /// + /// The source context. + /// public global::Google.Protobuf.WellKnownTypes.SourceContext SourceContext { get { return sourceContext_; } set { @@ -699,8 +870,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "syntax" field. public const int SyntaxFieldNumber = 5; private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2; + /// + /// The source syntax. + /// public global::Google.Protobuf.WellKnownTypes.Syntax Syntax { get { return syntax_; } set { @@ -830,6 +1005,9 @@ namespace Google.Protobuf.WellKnownTypes { } + /// + /// Enum value definition. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class EnumValue : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EnumValue()); @@ -859,8 +1037,12 @@ namespace Google.Protobuf.WellKnownTypes { return new EnumValue(this); } + /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + /// + /// Enum value name. + /// public string Name { get { return name_; } set { @@ -868,8 +1050,12 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "number" field. public const int NumberFieldNumber = 2; private int number_; + /// + /// Enum value number. + /// public int Number { get { return number_; } set { @@ -877,10 +1063,14 @@ namespace Google.Protobuf.WellKnownTypes { } } + /// Field number for the "options" field. public const int OptionsFieldNumber = 3; private static readonly pb::FieldCodec _repeated_options_codec = pb::FieldCodec.ForMessage(26, global::Google.Protobuf.WellKnownTypes.Option.Parser); private readonly pbc::RepeatedField options_ = new pbc::RepeatedField(); + /// + /// Proto options for the enum value. + /// public pbc::RepeatedField Options { get { return options_; } } @@ -976,6 +1166,9 @@ namespace Google.Protobuf.WellKnownTypes { } + /// + /// Proto option attached to messages/fields/enums etc. + /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Option : pb::IMessage