mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-09 22:56:27 +00:00
[C#] Use @ for keyword escaping (#6834)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user