private static IntPtr ToNativeNodeTasks(PinCollection pinCollection, ReadOnlyCollection <NodeTaskDescription> nodeTasks)
        {
            var nativeArray = new NativeInfrastructureService.FABRIC_NODE_TASK_DESCRIPTION[nodeTasks.Count];

            for (int ix = 0; ix < nodeTasks.Count; ++ix)
            {
                nativeArray[ix].NodeName = pinCollection.AddObject(nodeTasks[ix].NodeName);
                nativeArray[ix].TaskType = ToNativeTaskType(nodeTasks[ix].TaskType);
            }

            var nativeList = new NativeInfrastructureService.FABRIC_NODE_TASK_DESCRIPTION_LIST();

            nativeList.Count = (uint)nodeTasks.Count;
            nativeList.Items = pinCollection.AddBlittable(nativeArray);

            return(pinCollection.AddBlittable(nativeList));
        }
        private static unsafe ReadOnlyCollection <NodeTaskDescription> FromNativeNodeTasks(IntPtr nativePtr)
        {
            var castedPtr = (NativeInfrastructureService.FABRIC_NODE_TASK_DESCRIPTION_LIST *)nativePtr;

            var count  = castedPtr->Count;
            var result = new List <NodeTaskDescription>();

            var arrayPtr = (NativeInfrastructureService.FABRIC_NODE_TASK_DESCRIPTION *)castedPtr->Items;

            for (int ix = 0; ix < count; ++ix)
            {
                NativeInfrastructureService.FABRIC_NODE_TASK_DESCRIPTION item = *(arrayPtr + ix);

                var nodeTask = new NodeTaskDescription();
                nodeTask.NodeName = NativeTypes.FromNativeString(item.NodeName);
                nodeTask.TaskType = FromNativeTaskType(item.TaskType);

                result.Add(nodeTask);
            }

            return(new ReadOnlyCollection <NodeTaskDescription>(result));
        }