Dogacel / kotlinx-protobuf-gen

Generate kotlinx serializable data classes from protobuf
Apache License 2.0
12 stars 3 forks source link

Fix Gen Class Without Any Properties #15

Closed tamnguyenhuy closed 1 year ago

tamnguyenhuy commented 1 year ago

Change fix generate class without Any Properties

syntax = "proto3";

message Hello {
  enum Type {
    UNKNOWN = 0;
    KNOWN = 1;
  }
  message SubHello {
    message HelloExtend {
      optional Type type = 1;
    }
    optional SubHello subHello = 1;
  }
}

Result

package testgen

import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber

@Serializable
public class Hello {
  @Serializable
  public data class SubHello(
    @ProtoNumber(number = 1)
    public var subHello: SubHello? = null,
  ) {
    @Serializable
    public data class HelloExtend(
      @ProtoNumber(number = 1)
      public var type: Type? = null,
    )
  }

  @Serializable
  public enum class Type {
    @ProtoNumber(number = 0)
    UNKNOWN,
    @ProtoNumber(number = 1)
    KNOWN,
  }
}

Fixes #20

tamnguyenhuy commented 1 year ago

@Dogacel please help to take a look at my PR and let me know your thought!! Thanks

codecov-commenter commented 1 year ago

Welcome to Codecov :tada:

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered :open_umbrella:

Dogacel commented 1 year ago

@tamnguyenhuy

I have added some additional checks to make sure we generate the code. Also updated codecov to show coverage info.

I had to merge latest main into your PR to see those. Don't forget to fetch remote 😉