square / square/wire

wire-grade-plugin strips deprecated option from EnumTypes

Open
#3,075 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
4.4k
Forks
627
Avg merge
3d 15m
Merged PRs (30d)
20

Description

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),
  ;

...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using test/period.proto and inspect the generated build/Period.kt for the missing @Deprecated annotation. Start by tracing the pruning functionality described in the issue, then verify that deprecated enum options are retained while existing enum constant, message, and field behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.