1// Protocol Buffers - Google's data interchange format 2// Copyright 2008 Google Inc. All rights reserved. 3// 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file or at 6// https://developers.google.com/open-source/licenses/bsd 7 8syntax = "proto3"; 9 10package protobuf_unittest; 11 12import "google/protobuf/descriptor.proto"; 13 14option csharp_namespace = "ProtobufUnittest"; 15option java_multiple_files = true; 16option java_package = "com.google.protobuf.testing.proto"; 17 18message TestProto3Optional { 19 message NestedMessage { 20 // The field name "b" fails to compile in proto1 because it conflicts with 21 // a local variable named "b" in one of the generated methods. Doh. 22 // This file needs to compile in proto1 to test backwards-compatibility. 23 optional int32 bb = 1; 24 } 25 26 enum NestedEnum { 27 UNSPECIFIED = 0; 28 FOO = 1; 29 BAR = 2; 30 BAZ = 3; 31 NEG = -1; // Intentionally negative. 32 } 33 34 // Singular 35 optional int32 optional_int32 = 1; 36 optional int64 optional_int64 = 2; 37 optional uint32 optional_uint32 = 3; 38 optional uint64 optional_uint64 = 4; 39 optional sint32 optional_sint32 = 5; 40 optional sint64 optional_sint64 = 6; 41 optional fixed32 optional_fixed32 = 7; 42 optional fixed64 optional_fixed64 = 8; 43 optional sfixed32 optional_sfixed32 = 9; 44 optional sfixed64 optional_sfixed64 = 10; 45 optional float optional_float = 11; 46 optional double optional_double = 12; 47 optional bool optional_bool = 13; 48 optional string optional_string = 14; 49 optional bytes optional_bytes = 15; 50 optional string optional_cord = 16 [ctype = CORD]; 51 52 optional NestedMessage optional_nested_message = 18; 53 optional NestedMessage lazy_nested_message = 19 [lazy = true]; 54 optional NestedEnum optional_nested_enum = 21; 55 56 // Add some non-optional fields to verify we can mix them. 57 int32 singular_int32 = 22; 58 int64 singular_int64 = 23; 59} 60 61message TestProto3OptionalMessage { 62 message NestedMessage { 63 string s = 1; 64 } 65 66 NestedMessage nested_message = 1; 67 optional NestedMessage optional_nested_message = 2; 68} 69 70message Proto3OptionalExtensions { 71 option (protobuf_unittest.Proto3OptionalExtensions.ext_no_optional) = 8; 72 option (protobuf_unittest.Proto3OptionalExtensions.ext_with_optional) = 16; 73 74 extend google.protobuf.MessageOptions { 75 int32 ext_no_optional = 355886728; 76 optional int32 ext_with_optional = 355886729; 77 } 78} 79