[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:
mustiikhalil
2020-07-27 19:57:50 +03:00
committed by GitHub
parent 5d052f4e55
commit f1025b2847
6 changed files with 70 additions and 12 deletions

View File

@@ -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>();