internal static new unsafe ExeHostEntryPointDescription CreateFromNative(IntPtr entryPointDescriptionPtr)
        {
            NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION *nativeEntryPointDescription = (NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION *)entryPointDescriptionPtr;

            ExeHostEntryPointDescription entryPointDescription = new ExeHostEntryPointDescription
            {
                Program       = NativeTypes.FromNativeString(nativeEntryPointDescription->Program),
                Arguments     = NativeTypes.FromNativeString(nativeEntryPointDescription->Arguments),
                WorkingFolder = (ExeHostWorkingFolder)nativeEntryPointDescription->WorkingFolder
            };

            if (nativeEntryPointDescription->Reserved != IntPtr.Zero)
            {
                NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION_EX1 *nativeEntryPointDescriptionEx1 = (NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION_EX1 *)nativeEntryPointDescription->Reserved;
                entryPointDescription.PeriodicInterval          = nativeEntryPointDescriptionEx1->PeriodicIntervalInSeconds;
                entryPointDescription.ConsoleRedirectionEnabled = NativeTypes.FromBOOLEAN(nativeEntryPointDescriptionEx1->ConsoleRedirectionEnabled);

                // XSD has types as int for the following fields. Also minimum limit has been set to value > 0. Hence the cast is safe.
                entryPointDescription.ConsoleRedirectionFileRetentionCount = (long)nativeEntryPointDescriptionEx1->ConsoleRedirectionFileRetentionCount;
                entryPointDescription.ConsoleRedirectionFileMaxSizeInKb    = (long)nativeEntryPointDescriptionEx1->ConsoleRedirectionFileMaxSizeInKb;

                if (nativeEntryPointDescriptionEx1->Reserved != IntPtr.Zero)
                {
                    NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION_EX2 *nativeEntryPointDescriptionEx2 = (NativeTypes.FABRIC_EXEHOST_ENTRY_POINT_DESCRIPTION_EX2 *)nativeEntryPointDescriptionEx1->Reserved;
                    entryPointDescription.IsExternalExecutable = NativeTypes.FromBOOLEAN(nativeEntryPointDescriptionEx2->IsExternalExecutable);
                }
            }

            return(entryPointDescription);
        }
        internal static unsafe CodePackageDescription CreateFromNative(NativeTypes.FABRIC_CODE_PACKAGE_DESCRIPTION nativeDescription, string path)
        {
            string packageName = NativeTypes.FromNativeString(nativeDescription.Name);

            AppTrace.TraceSource.WriteNoise("CodePackageDescription.CreateFromNative", "PackageName {0}", packageName);

            ExeHostEntryPointDescription setupEntryPoint = null;

            if (nativeDescription.SetupEntryPoint != IntPtr.Zero)
            {
                setupEntryPoint = ExeHostEntryPointDescription.CreateFromNative(nativeDescription.SetupEntryPoint);
            }

            if (nativeDescription.EntryPoint == IntPtr.Zero)
            {
                AppTrace.TraceSource.WriteError("CodePackageDescription.CreateFromNative", "No EntryPoint");
                throw new ArgumentException(StringResources.Error_NoEntryPoint);
            }
            var entryPoint = EntryPointDescription.CreateFromNative(nativeDescription.EntryPoint);


            return(new CodePackageDescription
            {
                Name = packageName,
                Version = NativeTypes.FromNativeString(nativeDescription.Version),
                ServiceManifestName = NativeTypes.FromNativeString(nativeDescription.ServiceManifestName),
                ServiceManifestVersion = NativeTypes.FromNativeString(nativeDescription.ServiceManifestVersion),
                IsShared = NativeTypes.FromBOOLEAN(nativeDescription.IsShared),
#pragma warning disable 618
                Path = path,
#pragma warning restore 618
                SetupEntryPoint = setupEntryPoint,
                EntryPoint = entryPoint,
            });
        }
        internal static unsafe EntryPointDescription CreateFromNative(IntPtr entryPointDescriptionPtr)
        {
            NativeTypes.FABRIC_CODE_PACKAGE_ENTRY_POINT_DESCRIPTION *nativeEntryPointDescription = (NativeTypes.FABRIC_CODE_PACKAGE_ENTRY_POINT_DESCRIPTION *)entryPointDescriptionPtr;

            switch (nativeEntryPointDescription->Kind)
            {
            case NativeTypes.FABRIC_CODE_PACKAGE_ENTRY_POINT_KIND.FABRIC_CODE_PACKAGE_ENTRY_POINT_KIND_EXEHOST:
                return(ExeHostEntryPointDescription.CreateFromNative(nativeEntryPointDescription->Value));

            case NativeTypes.FABRIC_CODE_PACKAGE_ENTRY_POINT_KIND.FABRIC_CODE_PACKAGE_ENTRY_POINT_KIND_DLLHOST:
                return(DllHostEntryPointDescription.CreateFromNative(nativeEntryPointDescription->Value));

            case NativeTypes.FABRIC_CODE_PACKAGE_ENTRY_POINT_KIND.FABRIC_CODE_PACKAGE_ENTRY_POINT_KIND_CONTAINERHOST:
                return(ContainerHostEntryPointDescription.CreateFromNative(nativeEntryPointDescription->Value));

            default:
                AppTrace.TraceSource.WriteError("EntryPointDescription.CreateFromNative", "Unknown code package entry point type : {0}", nativeEntryPointDescription->Kind);
                ReleaseAssert.Failfast(string.Format(CultureInfo.CurrentCulture, StringResources.Error_UnknownCodePackageEntryType_Formatted, nativeEntryPointDescription->Kind));
                return(null);
            }
        }