Skip to content

Recognize well-known types #7

Open
@mgravell

Description

@mgravell

for APIs that involve, say, DateTime (rather than custom message types) we should try to pick the most reasonable looking well-known-type and use that;

obvious candidates:

  • DateTime / .google.protobuf.Timestamp (corelogic readily available in protobuf-net; BclHelpers.ReadTimeStamp / WriteTimestamp)
  • TimeSpan / .google.protobuf.Duration (core logic readily available in protobuf-net; BclHelpers.ReadDuration / WriteDuration)
  • void / .google.protobuf.Empty (already handled, but should migrate to the new Empty in protobuf-net)

the following probably already work fine (not sure about byte[]), as "assume a message with a single field with index 1" is the default behavior already:

  • double / .google.protobuf.DoubleValue (wrappers.proto)
  • float / .google.protobuf.FloatValue (wrappers.proto)
  • long / .google.protobuf.Int64Value (wrappers.proto)
  • ulong / .google.protobuf.UInt64Value (wrappers.proto)
  • int / .google.protobuf.Int32Value (wrappers.proto)
  • uint / .google.protobuf.UInt32Value (wrappers.proto)
  • bool / .google.protobuf.BoolValue (wrappers.proto)
  • string / .google.protobuf.StringValue (wrappers.proto)
  • byte[] / .google.protobuf.BytesValue (wrappers.proto)

Note: with the above, we should probably hard remove the ability to opt in/out of data-contract types on the marshaller; it should be "nope, it is either something we recognize, or a data-contract type".

Note: we should also think about null in the above; since outer-most message don't include a length prefix, this could be awkward - since wrappers.proto is proto3, that means that there is no way of expressing a difference between 0 and null. Maybe we just don't support nulls ?

less obvious - the only ones I can see us even considering are Type and Api

  • .google.protobuf.Any (any.proto) - mostly because I haven't seen this used to know the full intent
  • .google.protobuf.Api (api.proto) - possibly maps to Type when service-contract?
  • .google.protobuf.Type (type.proto) - possibly maps to Type when data-contract?
  • .google.protobuf.FieldMask (field_mask.proto) - very bespoke; not implemented
  • .google.protobuf.SourceContext (source_context.proto) - kinda like Assembly maybe?
  • .google.protobuf.Struct - think Dictionary<string, .google.protobuf.Value>
  • .google.protobuf.Value - a catch all for several other types; object maybe? or is that Any?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions