public void JsPropertyIdCanBeCopied() { var str = "foo"; using (var runtimeHandle = Engine.JsCreateRuntime(JavaScriptRuntimeAttributes.None, null)) { using (var contextHandle = Engine.JsCreateContext(runtimeHandle)) { Engine.JsSetCurrentContext(contextHandle); var propertyHandle = Engine.JsCreatePropertyId(str, (ulong)str.Length); //Get the size var size = Engine.JsCopyPropertyId(propertyHandle, null, 0); if ((int)size > int.MaxValue) { throw new OutOfMemoryException("Exceeded maximum string length."); } byte[] result = new byte[(int)size]; var written = Engine.JsCopyPropertyId(propertyHandle, result, (ulong)result.Length); string resultStr = Encoding.UTF8.GetString(result, 0, result.Length); Assert.True(str == resultStr); propertyHandle.Dispose(); } } }