Since Size2D converts Width/Height from float to int internally,
Width/Height values may be greater than int.MaxValue or less than
int.MinValue.
To resolve the above issue, Width/Height values are checked if they
are greater than int.MaxValue or less than int.MinValue.
{
float ret = Interop.Vector2.WidthGet(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
- return (int)ret;
+ return ClampToInt(ret);
}
}
{
float ret = Interop.Vector2.HeightGet(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
- return (int)ret;
+ return ClampToInt(ret);
}
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
+
+ private static int ClampToInt(double v) =>
+ v > int.MaxValue ? int.MaxValue
+ : v < int.MinValue ? int.MinValue
+ : (int)v;
}
}