1

I have a field of an enum type that I would like to deprecate. No clients use this field or its enum type. I want to reserve all of the values in this enum so that it cannot be reused.

message Example {
    ...
    enum Foo {
        BAR = 0;
        BAZ = 1;
    }
    Foo foo = 42;
}

My first thought was to try reserving the values from 0 to max as follows:

message Example {
    ...
    enum Foo {
        reserved "BAR", "BAZ";
        reserved 0 to max;
    }
    reserved "foo";
    reserved 42;
}

However, I get an error stating that Foo must contain at least one value. Is there any way to deprecate an entire enum like this in order to make sure it isn't reused?

cascal
  • 2,943
  • 2
  • 17
  • 19

1 Answers1

0

Although you can't reserve an entire enum (as far as I know since a zero value is required), you can reserve anything that ever was in it, and every use of it.

message Example {
    ...
    enum Foo {
        reserved "BAR", "BAZ";
        reserved 1 to max;
        RESERVED = 0;
    }
    reserved "foo";
    reserved 42;
}