// 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;
    }
  }
}

enum EnumFeature {
  TEST_ENUM_FEATURE_UNKNOWN = 0;
  VALUE1 = 1;
  VALUE2 = 2;
  VALUE3 = 3;
  VALUE4 = 4;
  VALUE5 = 5;
  VALUE6 = 6;
  VALUE7 = 7;
  VALUE8 = 8;
  VALUE9 = 9;
  VALUE10 = 10;
  VALUE11 = 11;
  VALUE12 = 12;
  VALUE13 = 13;
  VALUE14 = 14;
  VALUE15 = 15;
}

message TestFeatures {
  optional EnumFeature file_feature = 1 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FILE,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" },
    edition_defaults = { edition: EDITION_PROTO3, value: "VALUE2" },
    edition_defaults = { edition: EDITION_2023, value: "VALUE3" },
    edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "VALUE4" },
    edition_defaults = { edition: EDITION_99998_TEST_ONLY, value: "VALUE5" }
  ];
  optional EnumFeature extension_range_feature = 2 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_EXTENSION_RANGE,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];
  optional EnumFeature message_feature = 3 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_MESSAGE,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];
  optional EnumFeature field_feature = 4 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FIELD,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];
  optional EnumFeature oneof_feature = 5 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_ONEOF,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];
  optional EnumFeature enum_feature = 6 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_ENUM,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];
  optional EnumFeature enum_entry_feature = 7 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_ENUM_ENTRY,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];
  optional EnumFeature service_feature = 8 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_SERVICE,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];
  optional EnumFeature method_feature = 9 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_METHOD,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];
  optional EnumFeature 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,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];

  optional bool bool_field_feature = 11 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FIELD,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "false" },
    edition_defaults = { edition: EDITION_99997_TEST_ONLY, value: "true" }
  ];

  optional EnumFeature 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,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];

  optional EnumFeature source_feature2 = 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,
    feature_support.edition_introduced = EDITION_2023,
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" }
  ];

  optional EnumFeature removed_feature = 17 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FILE,
    targets = TARGET_TYPE_FIELD,
    feature_support = {
      edition_introduced: EDITION_2023
      edition_deprecated: EDITION_2023
      deprecation_warning: "Custom feature deprecation warning"
      edition_removed: EDITION_2024
    },
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" },
    edition_defaults = { edition: EDITION_2023, value: "VALUE2" },
    edition_defaults = { edition: EDITION_2024, value: "VALUE3" }
  ];

  optional EnumFeature future_feature = 18 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FILE,
    targets = TARGET_TYPE_FIELD,
    feature_support = { edition_introduced: EDITION_2024 },
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" },
    edition_defaults = { edition: EDITION_2024, value: "VALUE2" }
  ];

  optional EnumFeature legacy_feature = 19 [
    retention = RETENTION_RUNTIME,
    targets = TARGET_TYPE_FILE,
    targets = TARGET_TYPE_FIELD,
    feature_support = {
      edition_introduced: EDITION_PROTO2
      edition_removed: EDITION_2023
    },
    edition_defaults = { edition: EDITION_LEGACY, value: "VALUE1" },
    edition_defaults = { edition: EDITION_2023, value: "VALUE2" }
  ];
}
