[C#] Use @ for keyword escaping (#6834)

This commit is contained in:
Derek Bailey
2021-09-09 10:29:27 -07:00
committed by GitHub
parent 1d063d87cf
commit 8fb8c2ce1d
19 changed files with 111 additions and 164 deletions

View File

@@ -19,6 +19,7 @@ using System.Text;
using System.Threading;
using MyGame.Example;
using optional_scalars;
using KeywordTest;
namespace FlatBuffers.Test
{
@@ -1117,5 +1118,26 @@ namespace FlatBuffers.Test
Assert.AreEqual(OptionalByte.Two, scalarStuff.MaybeEnum);
Assert.AreEqual(OptionalByte.Two, scalarStuff.DefaultEnum);
}
[FlatBuffersTestMethod]
public void TestKeywordEscaping() {
Assert.AreEqual((int)KeywordTest.@public.NONE, 0);
Assert.AreEqual((int)KeywordTest.ABC.@void, 0);
Assert.AreEqual((int)KeywordTest.ABC.where, 1);
Assert.AreEqual((int)KeywordTest.ABC.@stackalloc, 2);
var fbb = new FlatBufferBuilder(1);
var offset = KeywordsInTable.CreateKeywordsInTable(
fbb, KeywordTest.ABC.@stackalloc, KeywordTest.@public.NONE);
fbb.Finish(offset.Value);
KeywordsInTable keywordsInTable =
KeywordsInTable.GetRootAsKeywordsInTable(fbb.DataBuffer);
Assert.AreEqual(keywordsInTable.Is, KeywordTest.ABC.@stackalloc);
Assert.AreEqual(keywordsInTable.Private, KeywordTest.@public.NONE);
}
}
}