// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc.  All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

syntax = "proto3";

package protobuf_unittest;

import "google/protobuf/descriptor.proto";

option csharp_namespace = "ProtobufUnittest";
option java_multiple_files = true;
option java_package = "com.google.protobuf.testing.proto";

message TestProto3Optional {
  message NestedMessage {
    // The field name "b" fails to compile in proto1 because it conflicts with
    // a local variable named "b" in one of the generated methods.  Doh.
    // This file needs to compile in proto1 to test backwards-compatibility.
    optional int32 bb = 1;
  }

  enum NestedEnum {
    UNSPECIFIED = 0;
    FOO = 1;
    BAR = 2;
    BAZ = 3;
    NEG = -1;  // Intentionally negative.
  }

  // Singular
  optional int32 optional_int32 = 1;
  optional int64 optional_int64 = 2;
  optional uint32 optional_uint32 = 3;
  optional uint64 optional_uint64 = 4;
  optional sint32 optional_sint32 = 5;
  optional sint64 optional_sint64 = 6;
  optional fixed32 optional_fixed32 = 7;
  optional fixed64 optional_fixed64 = 8;
  optional sfixed32 optional_sfixed32 = 9;
  optional sfixed64 optional_sfixed64 = 10;
  optional float optional_float = 11;
  optional double optional_double = 12;
  optional bool optional_bool = 13;
  optional string optional_string = 14;
  optional bytes optional_bytes = 15;
  optional string optional_cord = 16 [ctype = CORD];

  optional NestedMessage optional_nested_message = 18;
  optional NestedMessage lazy_nested_message = 19 [lazy = true];
  optional NestedEnum optional_nested_enum = 21;

  // Add some non-optional fields to verify we can mix them.
  int32 singular_int32 = 22;
  int64 singular_int64 = 23;
}

message TestProto3OptionalMessage {
  message NestedMessage {
    string s = 1;
  }

  NestedMessage nested_message = 1;
  optional NestedMessage optional_nested_message = 2;
}

message Proto3OptionalExtensions {
  option (protobuf_unittest.Proto3OptionalExtensions.ext_no_optional) = 8;
  option (protobuf_unittest.Proto3OptionalExtensions.ext_with_optional) = 16;

  extend google.protobuf.MessageOptions {
    int32 ext_no_optional = 355886728;
    optional int32 ext_with_optional = 355886729;
  }
}
