square / wire

gRPC and protocol buffers for Android, Kotlin, Swift and Java.
https://square.github.io/wire/
Apache License 2.0
4.23k stars 571 forks source link

wire-grade-plugin strips deprecated option from EnumTypes #3075

Open aaron-edwards opened 3 weeks ago

aaron-edwards commented 3 weeks ago

When generating java and kotlin enums that have the option deprecated = true; flag the resulting enum generated does not contain the @Deprecated annotation. This appears to be due to the pruning functionality not retaining the deprecated flag and only affects the enum classes (enum constants, messages and fields all work as expected)

test/period.proto

syntax = "proto2";

enum Period {
  option deprecated = true;
  CRETACEOUS = 1;
}

build/Period.kt

// Code generated by Wire protocol buffer compiler, do not edit.
// Source: Period in period.proto
@file:Suppress(
  "DEPRECATION",
  "RUNTIME_ANNOTATION_NOT_SUPPORTED",
)

import com.squareup.wire.EnumAdapter
import com.squareup.wire.ProtoAdapter
import com.squareup.wire.Syntax.PROTO_2
import com.squareup.wire.WireEnum
import com.squareup.wire.`internal`.JvmField
import com.squareup.wire.`internal`.JvmStatic
import kotlin.Int
import kotlin.Suppress

public enum class Period(
  override val `value`: Int,
) : WireEnum {
  CRETACEOUS(1),
  ;

...
oldergod commented 1 week ago

Thanks for the fix! Is there anything to do for this ticket?