Skip to content

Commit 499bae3

Browse files
committed
update common code tdsstateparserobject
revert some changes Update TdsParserStateObject.cs change bitconvertercompat to bitconvertercompatible
1 parent 6425b2a commit 499bae3

File tree

8 files changed

+19
-16
lines changed

8 files changed

+19
-16
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
<Compile Include="..\..\src\Microsoft\Data\Common\AdapterUtil.cs">
3434
<Link>Microsoft\Data\Common\AdapterUtil.cs</Link>
3535
</Compile>
36+
<Compile Include="..\..\src\Microsoft\Data\Common\BitConverterCompatible.cs">
37+
<Link>Microsoft\Data\Common\BitConverterCompatible.cs</Link>
38+
</Compile>
3639
<Compile Include="..\..\src\Microsoft\Data\Common\DbConnectionOptions.Common.cs">
3740
<Link>Microsoft\Data\Common\DbConnectionOptions.Common.cs</Link>
3841
</Compile>
@@ -623,7 +626,6 @@
623626
<Compile Include="Microsoft\Data\ProviderBase\DbConnectionPoolIdentity.cs" />
624627
<Compile Include="Microsoft\Data\SqlClient\AAsyncCallContext.cs" />
625628
<Compile Include="Microsoft\Data\SqlClient\AlwaysEncryptedHelperClasses.cs" />
626-
<Compile Include="Microsoft\Data\SqlClient\BitConverterCompat.cs"/>
627629
<Compile Include="Microsoft\Data\SqlClient\LocalDBAPI.cs" />
628630
<Compile Include="Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryLogicManager.NetCoreApp.cs" />
629631
<Compile Include="Microsoft\Data\SqlClient\SNI\ConcurrentQueueSemaphore.cs" />
@@ -1009,4 +1011,4 @@
10091011
<Import Project="$(ToolsDir)targets\ResolveContract.targets" Condition="'$(OSGroup)' == 'AnyOS'" />
10101012
<Import Project="$(ToolsDir)targets\NotSupported.targets" Condition="'$(OSGroup)' == 'AnyOS'" />
10111013
<Import Project="..\..\src\tools\targets\GenerateResourceStringsSource.targets" />
1012-
</Project>
1014+
</Project>

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.NetCoreApp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal sealed partial class TdsParser
1414

1515
internal static void FillDoubleBytes(double value, Span<byte> buffer) => BinaryPrimitives.TryWriteInt64LittleEndian(buffer, BitConverter.DoubleToInt64Bits(value));
1616

17-
internal static void FillFloatBytes(float value, Span<byte> buffer) => BinaryPrimitives.TryWriteInt32LittleEndian(buffer, BitConverterCompat.SingleToInt32Bits(value));
17+
internal static void FillFloatBytes(float value, Span<byte> buffer) => BinaryPrimitives.TryWriteInt32LittleEndian(buffer, BitConverterCompatible.SingleToInt32Bits(value));
1818

1919
internal static Guid ConstructGuid(ReadOnlySpan<byte> bytes)
2020
{

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ internal byte[] SerializeFloat(float v)
17811781
}
17821782

17831783
var bytes = new byte[4];
1784-
BinaryPrimitives.WriteInt32LittleEndian(bytes, BitConverterCompat.SingleToInt32Bits(v));
1784+
BinaryPrimitives.WriteInt32LittleEndian(bytes, BitConverterCompatible.SingleToInt32Bits(v));
17851785
return bytes;
17861786
}
17871787

@@ -5842,7 +5842,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
58425842
return false;
58435843
}
58445844

5845-
singleValue = BitConverterCompat.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(unencryptedBytes));
5845+
singleValue = BitConverterCompatible.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(unencryptedBytes));
58465846
value.Single = singleValue;
58475847
break;
58485848

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ internal void StartSession(object cancellationOwner)
279279
_cancellationOwner.Target = cancellationOwner;
280280
}
281281

282-
283282
/////////////////////////////////////////
284283
// Value Skip Logic //
285284
/////////////////////////////////////////

src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@
9595
<Compile Include="..\..\src\Microsoft\Data\Common\AdapterUtil.Windows.cs">
9696
<Link>Microsoft\Data\Common\AdapterUtil.Windows.cs</Link>
9797
</Compile>
98+
<Compile Include="..\..\src\Microsoft\Data\Common\BitConverterCompatible.cs">
99+
<Link>Microsoft\Data\Common\BitConverterCompatible.cs</Link>
100+
</Compile>
98101
<Compile Include="..\..\src\Microsoft\Data\Common\DbConnectionStringCommon.cs">
99102
<Link>Microsoft\Data\Common\DbConnectionStringCommon.cs</Link>
100103
</Compile>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Microsoft.Data.SqlClient
66
{
7-
internal static class BitConverterCompat
7+
internal static class BitConverterCompatible
88
{
99
public static unsafe int SingleToInt32Bits(float value)
1010
{

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ internal bool TryReadInt64(out long value)
13731373
Debug.Assert(_bTmpRead + bytesRead == 8, "TryReadByteArray returned true without reading all data required");
13741374
_bTmpRead = 0;
13751375
AssertValidState();
1376-
value = BitConverter.ToInt64(_bTmp, 0);
1376+
value = BinaryPrimitives.ReadInt64LittleEndian(_bTmp);
13771377
return true;
13781378
}
13791379
}
@@ -1382,7 +1382,7 @@ internal bool TryReadInt64(out long value)
13821382
// The entire long is in the packet and in the buffer, so just return it
13831383
// and take care of the counters.
13841384

1385-
value = BitConverter.ToInt64(_inBuff, _inBytesUsed);
1385+
value = BinaryPrimitives.ReadInt64LittleEndian(_inBuff.AsSpan(_inBytesUsed));
13861386

13871387
_inBytesUsed += 8;
13881388
_inBytesPacket -= 8;
@@ -1452,7 +1452,7 @@ internal bool TryReadUInt32(out uint value)
14521452
Debug.Assert(_bTmpRead + bytesRead == 4, "TryReadByteArray returned true without reading all data required");
14531453
_bTmpRead = 0;
14541454
AssertValidState();
1455-
value = BitConverter.ToUInt32(_bTmp, 0);
1455+
value = BinaryPrimitives.ReadUInt32LittleEndian(_bTmp);
14561456
return true;
14571457
}
14581458
}
@@ -1461,7 +1461,7 @@ internal bool TryReadUInt32(out uint value)
14611461
// The entire int is in the packet and in the buffer, so just return it
14621462
// and take care of the counters.
14631463

1464-
value = BitConverter.ToUInt32(_inBuff, _inBytesUsed);
1464+
value = BinaryPrimitives.ReadUInt32LittleEndian(_inBuff.AsSpan(_inBytesUsed));
14651465

14661466
_inBytesUsed += 4;
14671467
_inBytesPacket -= 4;
@@ -1487,15 +1487,15 @@ internal bool TryReadSingle(out float value)
14871487
}
14881488

14891489
AssertValidState();
1490-
value = BitConverter.ToSingle(_bTmp, 0);
1490+
value = BitConverterCompatible.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(_bTmp));
14911491
return true;
14921492
}
14931493
else
14941494
{
14951495
// The entire float is in the packet and in the buffer, so just return it
14961496
// and take care of the counters.
14971497

1498-
value = BitConverter.ToSingle(_inBuff, _inBytesUsed);
1498+
value = BitConverterCompatible.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(_inBuff.AsSpan(_inBytesUsed)));
14991499

15001500
_inBytesUsed += 4;
15011501
_inBytesPacket -= 4;
@@ -1521,15 +1521,15 @@ internal bool TryReadDouble(out double value)
15211521
}
15221522

15231523
AssertValidState();
1524-
value = BitConverter.ToDouble(_bTmp, 0);
1524+
value = BitConverter.Int64BitsToDouble(BinaryPrimitives.ReadInt64LittleEndian(_bTmp));
15251525
return true;
15261526
}
15271527
else
15281528
{
15291529
// The entire double is in the packet and in the buffer, so just return it
15301530
// and take care of the counters.
15311531

1532-
value = BitConverter.ToDouble(_inBuff, _inBytesUsed);
1532+
value = BitConverter.Int64BitsToDouble(BinaryPrimitives.ReadInt64LittleEndian(_inBuff.AsSpan(_inBytesUsed)));
15331533

15341534
_inBytesUsed += 8;
15351535
_inBytesPacket -= 8;

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsValueSetter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ internal void SetDateTimeOffset(DateTimeOffset value)
705705
_stateObj.WriteByteArray(BitConverter.GetBytes(time), length - 5, 0); // time
706706
_stateObj.WriteByteArray(BitConverter.GetBytes(days), 3, 0); // date
707707
#endif
708-
709708
_stateObj.WriteByte((byte)(offset & 0xff)); // offset byte 1
710709
_stateObj.WriteByte((byte)((offset >> 8) & 0xff)); // offset byte 2
711710
}

0 commit comments

Comments
 (0)