diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 6488aad..b087158 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,6 +1,6 @@ version: 0.1 cli: - version: 0.10.1-beta + version: 0.11.0-beta lint: enabled: - gitleaks@8.7.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index e009d42..ede0bf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## Fixes + +- Fixing issue where generated `decode` functions for slices would not allocate the proper memory before decoding the slice values (Issue #108) + +## Changes + +- Updating Trunk Linter to `v0.11.0-beta` + ## [v0.4.5] - 2022-04-22 (Beta) ## Fixes diff --git a/protoc-gen-frisbee/examples/simple/simple.proto b/protoc-gen-frisbee/examples/simple/simple.proto index e8a86b1..d0a796c 100644 --- a/protoc-gen-frisbee/examples/simple/simple.proto +++ b/protoc-gen-frisbee/examples/simple/simple.proto @@ -19,4 +19,9 @@ message Request { message Response{ string Message = 1; +} + +message SliceResponse { + repeated Response ResponseSlice = 1; + map ResponseMap = 2; } \ No newline at end of file diff --git a/protoc-gen-frisbee/templates/decode.templ b/protoc-gen-frisbee/templates/decode.templ index bdbfe7d..8dc6e7d 100644 --- a/protoc-gen-frisbee/templates/decode.templ +++ b/protoc-gen-frisbee/templates/decode.templ @@ -53,6 +53,9 @@ func (x *{{CamelCase .FullName}}) decode(d *packet.Decoder) error { for i := uint32(0); i < sliceSize; i++ { {{ $decoder := GetLUTDecoder $field.Kind -}} {{ if eq $field.Kind 11 -}} {{/* protoreflect.MessageKind */ -}} + if x.{{ CamelCaseName $field.Name }}[i] == nil { + x.{{ CamelCaseName $field.Name }}[i] = New{{ CamelCase $field.Message.FullName }}() + } err = x.{{ CamelCaseName $field.Name }}[i].decode(d) {{ else -}} x.{{ CamelCaseName $field.Name }}[i], err = d{{ $decoder }}()