#pragma warning disable 618

        internal unsafe void ToNative(PinCollection pin, ref NativeTypes.FABRIC_SERVICE_LOAD_METRIC_DESCRIPTION native)
        {
            native.Name = pin.AddBlittable(this.Name);
            native.PrimaryDefaultLoad   = checked ((uint)this.PrimaryDefaultLoad);
            native.SecondaryDefaultLoad = checked ((uint)this.SecondaryDefaultLoad);

            switch (this.Weight)
            {
            case ServiceLoadMetricWeight.Zero:
                native.Weight = NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_ZERO;
                break;

            case ServiceLoadMetricWeight.Low:
                native.Weight = NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_LOW;
                break;

            case ServiceLoadMetricWeight.Medium:
                native.Weight = NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_MEDIUM;
                break;

            case ServiceLoadMetricWeight.High:
                native.Weight = NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_HIGH;
                break;

            default:
                ReleaseAssert.Failfast(string.Format(CultureInfo.CurrentCulture, StringResources.Error_UnknownWeight_Formatted, this.Weight));
                break;
            }
        }
        internal static unsafe ServiceLoadMetricDescription CreateFromNative(IntPtr nativeRaw, bool isStateful)
        {
            NativeTypes.FABRIC_SERVICE_LOAD_METRIC_DESCRIPTION nativeMetric = *(NativeTypes.FABRIC_SERVICE_LOAD_METRIC_DESCRIPTION *)nativeRaw;

            ServiceLoadMetricDescription managed;

            if (isStateful)
            {
                managed = new StatefulServiceLoadMetricDescription();
            }
            else
            {
                managed = new StatelessServiceLoadMetricDescription();
            }

            managed.Name = NativeTypes.FromNativeString(nativeMetric.Name);

            switch (nativeMetric.Weight)
            {
            case NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_ZERO:
                managed.Weight = ServiceLoadMetricWeight.Zero;
                break;

            case NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_LOW:
                managed.Weight = ServiceLoadMetricWeight.Low;
                break;

            case NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_MEDIUM:
                managed.Weight = ServiceLoadMetricWeight.Medium;
                break;

            case NativeTypes.FABRIC_SERVICE_LOAD_METRIC_WEIGHT.FABRIC_SERVICE_LOAD_METRIC_WEIGHT_HIGH:
                managed.Weight = ServiceLoadMetricWeight.High;
                break;

            default:
                ReleaseAssert.Failfast(string.Format(CultureInfo.CurrentCulture, StringResources.Error_UnknownWeight_Formatted, nativeMetric.Weight));
                throw new ArgumentException(StringResources.Error_UnknownWeight);
            }

            managed.PrimaryDefaultLoad   = checked ((int)nativeMetric.PrimaryDefaultLoad);
            managed.SecondaryDefaultLoad = checked ((int)nativeMetric.SecondaryDefaultLoad);

            return(managed);
        }