Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align Type aliases between netfx and netcore #2957

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ internal void Connect(ServerInfo serverInfo,
_connHandler.TimeoutErrorInternal.EndPhase(SqlConnectionTimeoutErrorPhase.InitializeConnection);
_connHandler.TimeoutErrorInternal.SetAndBeginPhase(SqlConnectionTimeoutErrorPhase.SendPreLoginHandshake);

UInt32 result = SNINativeMethodWrapper.SniGetConnectionId(_physicalStateObj.Handle, ref _connHandler._clientConnectionId);
uint result = SNINativeMethodWrapper.SniGetConnectionId(_physicalStateObj.Handle, ref _connHandler._clientConnectionId);
Debug.Assert(result == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SniGetConnectionId");

// for DNS Caching phase 1
Expand Down Expand Up @@ -760,7 +760,7 @@ internal void Connect(ServerInfo serverInfo,
ThrowExceptionAndWarning(_physicalStateObj);
}

UInt32 retCode = SNINativeMethodWrapper.SniGetConnectionId(_physicalStateObj.Handle, ref _connHandler._clientConnectionId);
uint retCode = SNINativeMethodWrapper.SniGetConnectionId(_physicalStateObj.Handle, ref _connHandler._clientConnectionId);
Debug.Assert(retCode == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SniGetConnectionId");
SqlClientEventSource.Log.TryTraceEvent("<sc.TdsParser.Connect|SEC> Sending prelogin handshake");

Expand Down Expand Up @@ -864,7 +864,7 @@ internal void RemoveEncryption()
{
Debug.Assert((_encryptionOption & EncryptionOptions.OPTIONS_MASK) == EncryptionOptions.LOGIN, "Invalid encryption option state");

UInt32 error = 0;
uint error = 0;

// Remove SSL (Encryption) SNI provider since we only wanted to encrypt login.
error = SNINativeMethodWrapper.SNIRemoveProvider(_physicalStateObj.Handle, SNINativeMethodWrapper.ProviderEnum.SSL_PROV);
Expand All @@ -889,8 +889,8 @@ internal void EnableMars()
// Cache physical stateObj and connection.
_pMarsPhysicalConObj = _physicalStateObj;

UInt32 error = 0;
UInt32 info = 0;
uint error = 0;
uint info = 0;

// Add SMUX (MARS) SNI provider.
error = SNINativeMethodWrapper.SNIAddProvider(_pMarsPhysicalConObj.Handle, SNINativeMethodWrapper.ProviderEnum.SMUX_PROV, ref info);
Expand Down Expand Up @@ -1138,7 +1138,7 @@ private void SendPreLoginHandshake(
break;

case (int)PreLoginOptions.THREADID:
Int32 threadID = TdsParserStaticMethods.GetCurrentThreadIdForTdsLoginOnly();
int threadID = TdsParserStaticMethods.GetCurrentThreadIdForTdsLoginOnly();

payload[payloadLength++] = (byte)((0xff000000 & threadID) >> 24);
payload[payloadLength++] = (byte)((0x00ff0000 & threadID) >> 16);
Expand Down Expand Up @@ -1941,12 +1941,12 @@ internal void CheckResetConnection(TdsParserStateObject stateObj)
if (_fPreserveTransaction)
{
// if we are reseting, set bit in header by or'ing with other value
stateObj._outBuff[1] = (Byte)(stateObj._outBuff[1] | TdsEnums.ST_RESET_CONNECTION_PRESERVE_TRANSACTION);
stateObj._outBuff[1] = (byte)(stateObj._outBuff[1] | TdsEnums.ST_RESET_CONNECTION_PRESERVE_TRANSACTION);
}
else
{
// if we are reseting, set bit in header by or'ing with other value
stateObj._outBuff[1] = (Byte)(stateObj._outBuff[1] | TdsEnums.ST_RESET_CONNECTION);
stateObj._outBuff[1] = (byte)(stateObj._outBuff[1] | TdsEnums.ST_RESET_CONNECTION);
}

if (!_fMARS)
Expand Down Expand Up @@ -4885,7 +4885,7 @@ internal TdsOperationStatus TryProcessReturnValue(int length,

if (rec.metaType.IsPlp)
{
intlen = Int32.MaxValue; // If plp data, read it all
intlen = int.MaxValue; // If plp data, read it all
}

if (isNull)
Expand Down Expand Up @@ -4917,7 +4917,7 @@ internal TdsOperationStatus TryProcessTceCryptoMetadata(TdsParserStateObject sta

// Read the ordinal into cipher table
ushort index = 0;
UInt32 userType;
uint userType;
TdsOperationStatus result;

// For return values there is not cipher table and no ordinal.
Expand Down Expand Up @@ -6623,7 +6623,7 @@ internal TdsOperationStatus TrySkipValue(SqlMetaDataPriv md, int columnOrdinal,

if (md.metaType.IsPlp)
{
result = TrySkipPlpValue(UInt64.MaxValue, stateObj, out _);
result = TrySkipPlpValue(ulong.MaxValue, stateObj, out _);
if (result != TdsOperationStatus.Done)
{
return result;
Expand Down Expand Up @@ -6746,7 +6746,7 @@ private TdsOperationStatus TryReadSqlStringValue(SqlBuffer value, byte type, int
case TdsEnums.SQLNVARCHAR:
case TdsEnums.SQLNTEXT:
{
String s = null;
string s = null;

if (isPlp)
{
Expand Down Expand Up @@ -7783,23 +7783,23 @@ internal Task WriteSqlVariantValue(object value, int length, int offset, TdsPars
switch (mt.TDSType)
{
case TdsEnums.SQLFLT4:
WriteFloat((Single)value, stateObj);
WriteFloat((float)value, stateObj);
break;

case TdsEnums.SQLFLT8:
WriteDouble((Double)value, stateObj);
WriteDouble((double)value, stateObj);
break;

case TdsEnums.SQLINT8:
WriteLong((Int64)value, stateObj);
WriteLong((long)value, stateObj);
break;

case TdsEnums.SQLINT4:
WriteInt((Int32)value, stateObj);
WriteInt((int)value, stateObj);
break;

case TdsEnums.SQLINT2:
WriteShort((Int16)value, stateObj);
WriteShort((short)value, stateObj);
break;

case TdsEnums.SQLINT1:
Expand Down Expand Up @@ -7866,15 +7866,15 @@ internal Task WriteSqlVariantValue(object value, int length, int offset, TdsPars

case TdsEnums.SQLMONEY:
{
WriteCurrency((Decimal)value, 8, stateObj);
WriteCurrency((decimal)value, 8, stateObj);
break;
}

case TdsEnums.SQLNUMERICN:
{
stateObj.WriteByte(mt.Precision); //propbytes: precision
stateObj.WriteByte((byte)((Decimal.GetBits((Decimal)value)[3] & 0x00ff0000) >> 0x10)); // propbytes: scale
WriteDecimal((Decimal)value, stateObj);
stateObj.WriteByte((byte)((decimal.GetBits((decimal)value)[3] & 0x00ff0000) >> 0x10)); // propbytes: scale
WriteDecimal((decimal)value, stateObj);
break;
}

Expand Down Expand Up @@ -7932,27 +7932,27 @@ internal Task WriteSqlVariantDataRowValue(object value, TdsParserStateObject sta
{
case TdsEnums.SQLFLT4:
WriteSqlVariantHeader(6, metatype.TDSType, metatype.PropBytes, stateObj);
WriteFloat((Single)value, stateObj);
WriteFloat((float)value, stateObj);
break;

case TdsEnums.SQLFLT8:
WriteSqlVariantHeader(10, metatype.TDSType, metatype.PropBytes, stateObj);
WriteDouble((Double)value, stateObj);
WriteDouble((double)value, stateObj);
break;

case TdsEnums.SQLINT8:
WriteSqlVariantHeader(10, metatype.TDSType, metatype.PropBytes, stateObj);
WriteLong((Int64)value, stateObj);
WriteLong((long)value, stateObj);
break;

case TdsEnums.SQLINT4:
WriteSqlVariantHeader(6, metatype.TDSType, metatype.PropBytes, stateObj);
WriteInt((Int32)value, stateObj);
WriteInt((int)value, stateObj);
break;

case TdsEnums.SQLINT2:
WriteSqlVariantHeader(4, metatype.TDSType, metatype.PropBytes, stateObj);
WriteShort((Int16)value, stateObj);
WriteShort((short)value, stateObj);
break;

case TdsEnums.SQLINT1:
Expand Down Expand Up @@ -8031,16 +8031,16 @@ internal Task WriteSqlVariantDataRowValue(object value, TdsParserStateObject sta
case TdsEnums.SQLMONEY:
{
WriteSqlVariantHeader(10, metatype.TDSType, metatype.PropBytes, stateObj);
WriteCurrency((Decimal)value, 8, stateObj);
WriteCurrency((decimal)value, 8, stateObj);
break;
}

case TdsEnums.SQLNUMERICN:
{
WriteSqlVariantHeader(21, metatype.TDSType, metatype.PropBytes, stateObj);
stateObj.WriteByte(metatype.Precision); //propbytes: precision
stateObj.WriteByte((byte)((Decimal.GetBits((Decimal)value)[3] & 0x00ff0000) >> 0x10)); // propbytes: scale
WriteDecimal((Decimal)value, stateObj);
stateObj.WriteByte((byte)((decimal.GetBits((decimal)value)[3] & 0x00ff0000) >> 0x10)); // propbytes: scale
WriteDecimal((decimal)value, stateObj);
break;
}

Expand Down Expand Up @@ -8096,7 +8096,7 @@ private byte[] SerializeSqlMoney(SqlMoney value, int length, TdsParserStateObjec
private void WriteSqlMoney(SqlMoney value, int length, TdsParserStateObject stateObj)
{
// UNDONE: can I use SqlMoney.ToInt64()?
int[] bits = Decimal.GetBits(value.Value);
int[] bits = decimal.GetBits(value.Value);

// this decimal should be scaled by 10000 (regardless of what the incoming decimal was scaled by)
bool isNeg = (0 != (bits[3] & unchecked((int)0x80000000)));
Expand All @@ -8107,7 +8107,7 @@ private void WriteSqlMoney(SqlMoney value, int length, TdsParserStateObject stat

if (length == 4)
{
Decimal decimalValue = value.Value;
decimal decimalValue = value.Value;

// validate the value can be represented as a small money
if (decimalValue < TdsEnums.SQL_SMALL_MONEY_MIN || decimalValue > TdsEnums.SQL_SMALL_MONEY_MAX)
Expand Down Expand Up @@ -8167,10 +8167,10 @@ private byte[] SerializeCurrency(Decimal value, int length, TdsParserStateObject
return bytes;
}

private void WriteCurrency(Decimal value, int length, TdsParserStateObject stateObj)
private void WriteCurrency(decimal value, int length, TdsParserStateObject stateObj)
{
SqlMoney m = new SqlMoney(value);
int[] bits = Decimal.GetBits(m.Value);
int[] bits = decimal.GetBits(m.Value);

// this decimal should be scaled by 10000 (regardless of what the incoming decimal was scaled by)
bool isNeg = (0 != (bits[3] & unchecked((int)0x80000000)));
Expand Down Expand Up @@ -8288,7 +8288,7 @@ private byte[] SerializeDateTimeOffset(DateTimeOffset value, byte scale, int len
private void WriteDateTimeOffset(DateTimeOffset value, byte scale, int length, TdsParserStateObject stateObj)
{
WriteDateTime2(value.UtcDateTime, scale, length - 2, stateObj);
Int16 offset = (Int16)value.Offset.TotalMinutes;
short offset = (short)value.Offset.TotalMinutes;
stateObj.WriteByte((byte)(offset & 0xff));
stateObj.WriteByte((byte)((offset >> 8) & 0xff));
}
Expand Down Expand Up @@ -8482,7 +8482,7 @@ struct {

private void WriteDecimal(decimal value, TdsParserStateObject stateObj)
{
stateObj._decimalBits = Decimal.GetBits(value);
stateObj._decimalBits = decimal.GetBits(value);
Debug.Assert(stateObj._decimalBits != null, "decimalBits should be filled in at TdsExecuteRPC time");

/*
Expand Down Expand Up @@ -9621,7 +9621,7 @@ internal byte[] GetDTCAddress(int timeout, TdsParserStateObject stateObj)
long dtcLength = dtcReader.GetBytes(0, 0, null, 0, 0);

//
if (dtcLength <= Int32.MaxValue)
if (dtcLength <= int.MaxValue)
{
int cb = (int)dtcLength;

Expand Down Expand Up @@ -11551,10 +11551,10 @@ internal void WriteBulkCopyMetaData(_SqlMetaDataSet metadataCollection, int coun
}

// Write the flags
UInt16 flags;
flags = (UInt16)(md.Updatability << 2);
flags |= (UInt16)(md.IsNullable ? (UInt16)TdsEnums.Nullable : (UInt16)0);
flags |= (UInt16)(md.IsIdentity ? (UInt16)TdsEnums.Identity : (UInt16)0);
ushort flags;
flags = (ushort)(md.Updatability << 2);
flags |= (ushort)(md.IsNullable ? (ushort)TdsEnums.Nullable : (ushort)0);
flags |= (ushort)(md.IsIdentity ? (ushort)TdsEnums.Identity : (ushort)0);

// Write the next byte of flags
if (_serverSupportsColumnEncryption)
Expand Down Expand Up @@ -11995,7 +11995,7 @@ private int GetNotificationHeaderSize(SqlNotificationRequest notificationRequest
{
throw ADP.ArgumentNull("CallbackId");
}
else if (UInt16.MaxValue < callbackId.Length)
else if (ushort.MaxValue < callbackId.Length)
{
throw ADP.ArgumentOutOfRange("CallbackId");
}
Expand All @@ -12004,7 +12004,7 @@ private int GetNotificationHeaderSize(SqlNotificationRequest notificationRequest
{
throw ADP.ArgumentNull("Service");
}
else if (UInt16.MaxValue < service.Length)
else if (ushort.MaxValue < service.Length)
{
throw ADP.ArgumentOutOfRange("Service");
}
Expand Down Expand Up @@ -12049,9 +12049,9 @@ private void WriteQueryNotificationHeaderData(SqlNotificationRequest notificatio

// we did verification in GetNotificationHeaderSize, so just assert here.
Debug.Assert(callbackId != null, "CallbackId is null");
Debug.Assert(UInt16.MaxValue >= callbackId.Length, "CallbackId length is out of range");
Debug.Assert(ushort.MaxValue >= callbackId.Length, "CallbackId length is out of range");
Debug.Assert(service != null, "Service is null");
Debug.Assert(UInt16.MaxValue >= service.Length, "Service length is out of range");
Debug.Assert(ushort.MaxValue >= service.Length, "Service length is out of range");
Debug.Assert(-1 <= timeout, "Timeout");


Expand Down Expand Up @@ -12232,9 +12232,9 @@ private bool IsBOMNeeded(MetaType type, object value)
return true;
}
}
else if ((currentType == typeof(String)) && (((String)value).Length > 0))
else if ((currentType == typeof(string)) && (((String)value).Length > 0))
{
if ((value != null) && (((String)value)[0] & 0xff) != 0xff)
if ((value != null) && (((string)value)[0] & 0xff) != 0xff)
return true;
}
else if (currentType == typeof(SqlXml))
Expand Down Expand Up @@ -12439,7 +12439,7 @@ private Task WriteUnterminatedSqlValue(object value, MetaType type, int actualLe

if (type.FixedLength == 4)
{
if (0 > dt.DayTicks || dt.DayTicks > UInt16.MaxValue)
if (0 > dt.DayTicks || dt.DayTicks > ushort.MaxValue)
throw SQL.SmallDateTimeOverflow(dt.ToString());

WriteShort(dt.DayTicks, stateObj);
Expand Down Expand Up @@ -12996,11 +12996,11 @@ private Task WriteUnterminatedValue(object value, MetaType type, byte scale, int
{
case TdsEnums.SQLFLTN:
if (type.FixedLength == 4)
WriteFloat((Single)value, stateObj);
WriteFloat((float)value, stateObj);
else
{
Debug.Assert(type.FixedLength == 8, "Invalid length for SqlDouble type!");
WriteDouble((Double)value, stateObj);
WriteDouble((double)value, stateObj);
}

break;
Expand Down Expand Up @@ -13055,13 +13055,13 @@ private Task WriteUnterminatedValue(object value, MetaType type, byte scale, int
if (type.FixedLength == 1)
stateObj.WriteByte((byte)value);
else if (type.FixedLength == 2)
WriteShort((Int16)value, stateObj);
WriteShort((short)value, stateObj);
else if (type.FixedLength == 4)
WriteInt((Int32)value, stateObj);
WriteInt((int)value, stateObj);
else
{
Debug.Assert(type.FixedLength == 8, "invalid length for SqlIntN type: " + type.FixedLength.ToString(CultureInfo.InvariantCulture));
WriteLong((Int64)value, stateObj);
WriteLong((long)value, stateObj);
}

break;
Expand Down Expand Up @@ -13161,7 +13161,7 @@ private Task WriteUnterminatedValue(object value, MetaType type, byte scale, int
}
case TdsEnums.SQLNUMERICN:
Debug.Assert(type.FixedLength <= 17, "Decimal length cannot be greater than 17 bytes");
WriteDecimal((Decimal)value, stateObj);
WriteDecimal((decimal)value, stateObj);
break;

case TdsEnums.SQLDATETIMN:
Expand All @@ -13171,7 +13171,7 @@ private Task WriteUnterminatedValue(object value, MetaType type, byte scale, int

if (type.FixedLength == 4)
{
if (0 > dt.days || dt.days > UInt16.MaxValue)
if (0 > dt.days || dt.days > ushort.MaxValue)
throw SQL.SmallDateTimeOverflow(MetaType.ToDateTime(dt.days, dt.time, 4).ToString(CultureInfo.InvariantCulture));

WriteShort(dt.days, stateObj);
Expand All @@ -13187,7 +13187,7 @@ private Task WriteUnterminatedValue(object value, MetaType type, byte scale, int

case TdsEnums.SQLMONEYN:
{
WriteCurrency((Decimal)value, type.FixedLength, stateObj);
WriteCurrency((decimal)value, type.FixedLength, stateObj);
break;
}

Expand Down Expand Up @@ -13963,8 +13963,8 @@ internal TdsOperationStatus TrySkipPlpValue(ulong cb, TdsParserStateObject state
while ((totalBytesSkipped < cb) &&
(stateObj._longlenleft > 0))
{
if (stateObj._longlenleft > Int32.MaxValue)
bytesSkipped = Int32.MaxValue;
if (stateObj._longlenleft > int.MaxValue)
bytesSkipped = int.MaxValue;
else
bytesSkipped = (int)stateObj._longlenleft;
bytesSkipped = ((cb - totalBytesSkipped) < (ulong)bytesSkipped) ? (int)(cb - totalBytesSkipped) : bytesSkipped;
Expand Down
Loading