/// <inheritdoc/> protected override string?ConvertToValue(out ulong value) { long v = SimpleTypeConverter.ParseInt64(StringValue, long.MinValue, long.MaxValue, out var error); if (error is null) { value = (ulong)v; return(null); } value = SimpleTypeConverter.ParseUInt64(StringValue, ulong.MinValue, ulong.MaxValue, out error); return(error); }
static ulong?ParseIntegerConstant(CorElementType etype, string c, out string error) { error = null; long smin, smax; ulong max; switch (etype) { case CorElementType.Boolean: smin = 0; smax = 1; max = 1; break; case CorElementType.I: if (IntPtr.Size == 4) { goto case CorElementType.I4; } goto case CorElementType.I8; case CorElementType.U: case CorElementType.Ptr: case CorElementType.FnPtr: if (UIntPtr.Size == 4) { goto case CorElementType.U4; } goto case CorElementType.U8; case CorElementType.I1: case CorElementType.U1: smin = sbyte.MinValue; smax = sbyte.MaxValue; max = byte.MaxValue; break; case CorElementType.I2: case CorElementType.U2: smin = short.MinValue; smax = short.MaxValue; max = ushort.MaxValue; break; case CorElementType.I4: case CorElementType.U4: smin = int.MinValue; smax = int.MaxValue; max = uint.MaxValue; break; case CorElementType.I8: case CorElementType.U8: smin = long.MinValue; smax = long.MaxValue; max = ulong.MaxValue; break; default: return(null); } ulong v = SimpleTypeConverter.ParseUInt64(c, 0, max, out error); if (string.IsNullOrEmpty(error)) { return(v); } v = (ulong)SimpleTypeConverter.ParseInt64(c, smin, smax, out error); if (string.IsNullOrEmpty(error)) { return(v); } return(null); }