// Protocol Buffers - Google's data interchange format
// Copyright 2023 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 = "proto2";

package pb;

import "google/protobuf/descriptor.proto";

extend google.protobuf.FeatureSet {
  optional TestFeatures test = 9999;
}

message TestMessage {
  extend google.protobuf.FeatureSet {
    optional TestFeatures test_message = 9998;
  }
  message Nested {
    extend google.protobuf.FeatureSet {
      optional TestFeatures test_nested = 9997;
    }
  }
}

message TestFeatures {
  optional int32 int_file_feature = 1 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FILE,
    edition_defaults = { edition: EDITION_PROTO2, value: "-2" },
    edition_defaults = { edition: EDITION_PROTO3, value: "-3" },
    edition_defaults = { edition: EDITION_2023, value: "1" },
    edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "2" },
    edition_defaults = { edition: EDITION_99998_TEST_ONLY, value: "3" }
  ];
  optional int32 int_extension_range_feature = 2 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_EXTENSION_RANGE,
    edition_defaults = { edition: EDITION_PROTO2, value: "1" }
  ];
  optional int32 int_message_feature = 3 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_MESSAGE,
    edition_defaults = { edition: EDITION_PROTO2, value: "1" }
  ];
  optional int32 int_field_feature = 4 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FIELD,
    edition_defaults = { edition: EDITION_PROTO2, value: "1" }
  ];
  optional int32 int_oneof_feature = 5 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_ONEOF,
    edition_defaults = { edition: EDITION_PROTO2, value: "1" }
  ];
  optional int32 int_enum_feature = 6 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_ENUM,
    edition_defaults = { edition: EDITION_PROTO2, value: "1" }
  ];
  optional int32 int_enum_entry_feature = 7 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_ENUM_ENTRY,
    edition_defaults = { edition: EDITION_PROTO2, value: "1" }
  ];
  optional int32 int_service_feature = 8 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_SERVICE,
    edition_defaults = { edition: EDITION_PROTO2, value: "1" }
  ];
  optional int32 int_method_feature = 9 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_METHOD,
    edition_defaults = { edition: EDITION_PROTO2, value: "1" }
  ];
  optional int32 int_multiple_feature = 10 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FILE,
    targets = TARGET_TYPE_FIELD,
    targets = TARGET_TYPE_MESSAGE,
    targets = TARGET_TYPE_ENUM,
    targets = TARGET_TYPE_ENUM_ENTRY,
    targets = TARGET_TYPE_SERVICE,
    targets = TARGET_TYPE_METHOD,
    targets = TARGET_TYPE_ONEOF,
    targets = TARGET_TYPE_EXTENSION_RANGE,
    edition_defaults = { edition: EDITION_PROTO2, value: "1" }
  ];

  optional bool bool_field_feature = 11 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FIELD,
    edition_defaults = { edition: EDITION_PROTO2, value: "false" },
    edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "true" }
  ];
  optional float float_field_feature = 12 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FIELD,
    edition_defaults = { edition: EDITION_PROTO2, value: "1.1" },
    edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "1.2" }
  ];

  message MessageFeature {
    optional bool bool_field = 1;
    optional int32 int_field = 2;
    optional float float_field = 3;
    optional string string_field = 4;
  }
  optional MessageFeature message_field_feature = 13 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FIELD,
    edition_defaults = {
      edition: EDITION_99997_TEST_ONLY,
      value: "int_field: 2"
    },
    edition_defaults = {
      edition: EDITION_99998_TEST_ONLY,
      value: "string_field: '2024'"
    },
    edition_defaults = {
      edition: EDITION_2023,
      value: "bool_field: true int_field: 1 float_field: 1.5 string_field: '2023'"
    },
    edition_defaults = { edition: EDITION_PROTO2, value: "" }
  ];

  enum EnumFeature {
    TEST_ENUM_FEATURE_UNKNOWN = 0;
    ENUM_VALUE1 = 1;
    ENUM_VALUE2 = 2;
    ENUM_VALUE3 = 3;
    ENUM_VALUE4 = 4;
    ENUM_VALUE5 = 5;
  }
  optional EnumFeature enum_field_feature = 14 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FIELD,
    edition_defaults = {
      edition: EDITION_PROTO2,
      value: "TEST_ENUM_FEATURE_UNKNOWN"
    },
    edition_defaults = { edition: EDITION_2023, value: "ENUM_VALUE1" },
    edition_defaults = {
      edition: EDITION_99997_TEST_ONLY,
      value: "ENUM_VALUE2"
    },
    edition_defaults = {
      edition: EDITION_99998_TEST_ONLY,
      value: "ENUM_VALUE3"
    }
  ];

  optional int32 int_source_feature = 15 [
    retention = RETENTION_SOURCE,
    targets = TARGET_TYPE_FILE,
    targets = TARGET_TYPE_FIELD,
    targets = TARGET_TYPE_MESSAGE,
    targets = TARGET_TYPE_ENUM,
    targets = TARGET_TYPE_ENUM_ENTRY,
    targets = TARGET_TYPE_SERVICE,
    targets = TARGET_TYPE_METHOD,
    targets = TARGET_TYPE_ONEOF,
    targets = TARGET_TYPE_EXTENSION_RANGE,
    edition_defaults = { edition: EDITION_PROTO2, value: "1" }
  ];

  optional string string_source_feature = 16 [
    retention = RETENTION_SOURCE,
    targets = TARGET_TYPE_FILE,
    targets = TARGET_TYPE_FIELD,
    targets = TARGET_TYPE_MESSAGE,
    targets = TARGET_TYPE_ENUM,
    targets = TARGET_TYPE_ENUM_ENTRY,
    targets = TARGET_TYPE_SERVICE,
    targets = TARGET_TYPE_METHOD,
    targets = TARGET_TYPE_ONEOF,
    targets = TARGET_TYPE_EXTENSION_RANGE,
    edition_defaults = { edition: EDITION_PROTO2, value: "'2023'" }
  ];
}
