Skip to content

Commit

Permalink
change bitconvertercompat to bitconvertercompatible
Browse files Browse the repository at this point in the history
  • Loading branch information
saitama951 committed Dec 7, 2023
1 parent 2a6c33f commit 19d7865
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<Compile Include="..\..\src\Microsoft\Data\Common\AdapterUtil.cs">
<Link>Microsoft\Data\Common\AdapterUtil.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\Common\BitConverterCompatible.cs">
<Link>Microsoft\Data\Common\BitConverterCompatible.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\Common\DbConnectionOptions.Common.cs">
<Link>Microsoft\Data\Common\DbConnectionOptions.Common.cs</Link>
</Compile>
Expand Down Expand Up @@ -623,7 +626,6 @@
<Compile Include="Microsoft\Data\ProviderBase\DbConnectionPoolIdentity.cs" />
<Compile Include="Microsoft\Data\SqlClient\AAsyncCallContext.cs" />
<Compile Include="Microsoft\Data\SqlClient\AlwaysEncryptedHelperClasses.cs" />
<Compile Include="Microsoft\Data\SqlClient\BitConverterCompat.cs"/>
<Compile Include="Microsoft\Data\SqlClient\LocalDBAPI.cs" />
<Compile Include="Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryLogicManager.NetCoreApp.cs" />
<Compile Include="Microsoft\Data\SqlClient\SNI\ConcurrentQueueSemaphore.cs" />
Expand Down Expand Up @@ -1009,4 +1011,4 @@
<Import Project="$(ToolsDir)targets\ResolveContract.targets" Condition="'$(OSGroup)' == 'AnyOS'" />
<Import Project="$(ToolsDir)targets\NotSupported.targets" Condition="'$(OSGroup)' == 'AnyOS'" />
<Import Project="..\..\src\tools\targets\GenerateResourceStringsSource.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal sealed partial class TdsParser

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

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

internal static Guid ConstructGuid(ReadOnlySpan<byte> bytes)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ internal byte[] SerializeFloat(float v)
}

var bytes = new byte[4];
BinaryPrimitives.WriteInt32LittleEndian(bytes, BitConverterCompat.SingleToInt32Bits(v));
BinaryPrimitives.WriteInt32LittleEndian(bytes, BitConverterCompatible.SingleToInt32Bits(v));
return bytes;
}

Expand Down Expand Up @@ -5842,7 +5842,7 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt
return false;
}

singleValue = BitConverterCompat.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(unencryptedBytes));
singleValue = BitConverterCompatible.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(unencryptedBytes));
value.Single = singleValue;
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ internal void StartSession(object cancellationOwner)
_cancellationOwner.Target = cancellationOwner;
}


/////////////////////////////////////////
// Value Skip Logic //
/////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
<Compile Include="..\..\src\Microsoft\Data\Common\AdapterUtil.Windows.cs">
<Link>Microsoft\Data\Common\AdapterUtil.Windows.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\Common\BitConverterCompatible.cs">
<Link>Microsoft\Data\Common\BitConverterCompatible.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\Common\DbConnectionStringCommon.cs">
<Link>Microsoft\Data\Common\DbConnectionStringCommon.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Microsoft.Data.SqlClient
{
internal static class BitConverterCompat
internal static class BitConverterCompatible
{
public static unsafe int SingleToInt32Bits(float value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1487,15 +1487,15 @@ internal bool TryReadSingle(out float value)
}

AssertValidState();
value = BitConverterCompat.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(_bTmp));
value = BitConverterCompatible.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(_bTmp));
return true;
}
else
{
// The entire float is in the packet and in the buffer, so just return it
// and take care of the counters.

value = BitConverterCompat.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(_inBuff.AsSpan(_inBytesUsed)));
value = BitConverterCompatible.Int32BitsToSingle(BinaryPrimitives.ReadInt32LittleEndian(_inBuff.AsSpan(_inBytesUsed)));

_inBytesUsed += 4;
_inBytesPacket -= 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,6 @@ internal void SetDateTimeOffset(DateTimeOffset value)
_stateObj.WriteByteArray(BitConverter.GetBytes(time), length - 5, 0); // time
_stateObj.WriteByteArray(BitConverter.GetBytes(days), 3, 0); // date
#endif

_stateObj.WriteByte((byte)(offset & 0xff)); // offset byte 1
_stateObj.WriteByte((byte)((offset >> 8) & 0xff)); // offset byte 2
}
Expand Down

0 comments on commit 19d7865

Please sign in to comment.