public void AllocateTest() { var str = "foo-bar"; var p = NativeString.Wrap(str); Assert.Equal(str.Length, p.GetLen()); Assert.Equal(Encoding.UTF8.GetByteCount(str), p.GetBuffer().Length); Assert.Equal(Encoding.UTF8, p.GetEncoding()); Assert.Equal(NativeString.GetHashCode(str), p.GetHashCode()); }
internal unsafe void LoadMeta(byte[] meta) { using var steam = new MemoryStream(meta); while (steam.Position != steam.Length) { var template = MetaTemplate.FromBytes(steam.ReadBytes(sizeof(MetaTemplate))); if (template.type == TemplateType.STR) { StringLiteralMap.InternString(NativeString.Wrap(Encoding.UTF8.GetString(steam.ReadBytes(template.len)))); } if (template.type == TemplateType.RND) { steam.ReadBytes(template.len); } } }
public static void Asd() { native = NativeString.Wrap("test_string"); }