Skip to content

Commit

Permalink
[C#] Fix bug in string encoding method.
Browse files Browse the repository at this point in the history
Previously it would generate something like:

```
buffer.PutByte(someOffset, (ushort) someValue);
//                         ^^^^^^^^
```

Where the source value was too wide for the destination.
  • Loading branch information
ZachBray committed Sep 20, 2023
1 parent 1faedbb commit 3885a63
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,9 @@ private CharSequence generateVarData(final List<Token> tokens, final String inde
indent + INDENT + "int byteCount = _buffer.SetBytesFromString(encoding, value, " +
"limit + sizeOfLengthField);\n" +
indent + INDENT + "_parentMessage.Limit = limit + sizeOfLengthField + byteCount;\n" +
indent + INDENT + "_buffer.%3$sPut%4$s(limit, (ushort)byteCount);\n" +
indent + INDENT + "_buffer.%3$sPut%4$s(limit, (%5$s)byteCount);\n" +
indent + "}\n",
propertyName, sizeOfLengthField, lengthTypePrefix, byteOrderStr));
propertyName, sizeOfLengthField, lengthTypePrefix, byteOrderStr, lengthCSharpType));
}
}
}
Expand Down

0 comments on commit 3885a63

Please sign in to comment.