mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-27 09:22:17 +00:00
[Feature] Checks for Nullable strings (#6050)
* Allows null strings in createString method c# * Adds nullable strings to JS and swift * Changes js checks * Fixes typo
This commit is contained in:
@@ -554,6 +554,10 @@ namespace FlatBuffers
|
||||
/// </returns>
|
||||
public StringOffset CreateString(string s)
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
return new StringOffset(0);
|
||||
}
|
||||
NotNested();
|
||||
AddByte(0);
|
||||
var utf8StringLen = Encoding.UTF8.GetByteCount(s);
|
||||
@@ -594,6 +598,11 @@ namespace FlatBuffers
|
||||
/// </returns>
|
||||
public StringOffset CreateSharedString(string s)
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
return new StringOffset(0);
|
||||
}
|
||||
|
||||
if (_sharedStringMap == null)
|
||||
{
|
||||
_sharedStringMap = new Dictionary<string, StringOffset>();
|
||||
|
||||
Reference in New Issue
Block a user