• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Protocol Buffers - Google's data interchange format
2// Copyright 2023 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
8edition = "2023";
9
10// This file contains various edge cases we've collected from migrating real
11// protos in order to lock down the transformations.
12
13// LINT: ALLOW_GROUPS
14
15package protobuf_editions_test;
16
17import "net/proto/proto1_features.proto";
18import "google/protobuf/java_features.proto";
19import "google/protobuf/cpp_features.proto";
20import "editions/proto/editions_transform_proto3.proto";
21
22option features.repeated_field_encoding = EXPANDED;
23option features.utf8_validation = NONE;
24option java_api_version = 1;
25option java_multiple_files = true;
26option cc_enable_arenas = true;
27
28message EmptyMessage {
29}
30
31message EmptyMessage2 {
32}
33
34service EmptyService {
35}
36
37service BasicService {
38  rpc BasicMethod(EmptyMessage) returns (EmptyMessage) {}
39}
40
41// clang-format off
42message UnformattedMessage {
43  int32 a = 1;
44
45  message Foo {
46    int32 a = 1;
47  }
48
49  Foo foo = 2 [
50    features.message_encoding = DELIMITED
51  ];
52
53  string string_piece_with_zero = 3 [
54    ctype = STRING_PIECE,
55    default = "ab\000c"
56  ];
57
58  float long_float_name_wrapped = 4;
59}
60
61// clang-format on
62
63message ParentMessage {
64  message ExtendedMessage {
65    extensions 536860000 to 536869999 [
66      declaration = {
67        number: 536860000
68        full_name: ".protobuf_editions_test.extension"
69        type: ".protobuf_editions_test.EmptyMessage"
70      }
71    ];
72  }
73}
74
75extend ParentMessage.ExtendedMessage {
76  EmptyMessage extension = 536860000;
77}
78
79message TestMessage {
80  string string_field = 1;
81  map<string, string> string_map_field = 7;
82  repeated int32 int_field = 8;
83  repeated int32 int_field_packed = 9 [
84    features.repeated_field_encoding = PACKED,
85    features.(pb.proto1).legacy_packed = true
86  ];
87
88  repeated int32 int_field_unpacked = 10;
89  repeated int32 options_strip_beginning = 4 [
90    /* inline comment */
91    debug_redact = true,
92    deprecated = false
93  ];
94
95  repeated int32 options_strip_middle = 5 [
96    debug_redact = true,
97    deprecated = false
98  ];
99
100  repeated int32 options_strip_end = 6 [
101    debug_redact = true,
102    deprecated = false
103  ];
104
105  message OptionalGroup {
106    int32 a = 17;
107  }
108
109  OptionalGroup optionalgroup = 16 [
110    features.message_encoding = DELIMITED
111  ];
112}
113
114enum TestEnum {
115  option features.enum_type = CLOSED;
116
117  FOO = 1; // Non-zero default
118  BAR = 2;
119  BAZ = 3;
120  NEG = -1; // Intentionally negative.
121}
122
123message TestOpenEnumMessage {
124  TestEnumProto3 open_enum_field = 1 [
125    features.(pb.cpp).legacy_closed_enum = true,
126    features.(pb.java).legacy_closed_enum = true
127  ];
128
129  TestEnum closed_enum_field = 2;
130}
131