[#108] protogen: Distinguish between empty and nil messages
All checks were successful
DCO action / DCO (pull_request) Successful in 1m25s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m22s
Tests and linters / Tests (1.23) (pull_request) Successful in 1m29s
Tests and linters / Tests with -race (pull_request) Successful in 1m48s
Tests and linters / Lint (pull_request) Successful in 2m40s

Refs #59

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-08-27 10:53:43 +03:00
parent 5066af6ced
commit 9310d64742
18 changed files with 1 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -126,7 +126,6 @@ func testCompatibility(t *testing.T, msgGen func(empty bool) message.Message) {
}
}
t.Run("empty", func(t *testing.T) {
t.Skip()
msg := msgGen(true)
t.Run(fmt.Sprintf("Binary_%T", msg), func(t *testing.T) {
compareBinary(t, msg)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -174,7 +174,7 @@ func emitMarshalRaw(g *protogen.GeneratedFile, f *protogen.Field, name string) {
name += "[i]"
}
g.P("if ", notNil(name), " && ", name, ".StableSize() != 0 {")
g.P("if ", notNil(name), " {")
g.P(name, ".EmitProtobuf(mm.AppendMessage(", f.Desc.Number(), "))")
g.P("}")
return