Skip to content

Commit c79425e

Browse files
committed
Port PacketHandle to netfx
1 parent dc1298a commit c79425e

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,8 @@
878878
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs">
879879
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs</Link>
880880
</Compile>
881-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\PacketHandle.netcore.Windows.cs">
882-
<Link>Microsoft\Data\SqlClient\PacketHandle.netcore.Windows.cs</Link>
881+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\PacketHandle.Windows.cs">
882+
<Link>Microsoft\Data\SqlClient\PacketHandle.Windows.cs</Link>
883883
</Compile>
884884
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SessionHandle.Windows.cs">
885885
<Link>Microsoft\Data\SqlClient\SessionHandle.Windows.cs</Link>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@
447447
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Packet.cs">
448448
<Link>Microsoft\Data\SqlClient\Packet.cs</Link>
449449
</Compile>
450+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\PacketHandle.Windows.cs">
451+
<Link>Microsoft\Data\SqlClient\PacketHandle.Windows.cs</Link>
452+
</Compile>
450453
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\ParameterPeekAheadValue.cs">
451454
<Link>Microsoft\Data\SqlClient\ParameterPeekAheadValue.cs</Link>
452455
</Compile>

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Windows.cs renamed to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.Windows.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
#if NET
6-
75
using System;
86

97
namespace Microsoft.Data.SqlClient
@@ -22,21 +20,33 @@ internal readonly ref struct PacketHandle
2220
{
2321
public const int NativePointerType = 1;
2422
public const int NativePacketType = 2;
23+
#if NET
2524
public const int ManagedPacketType = 3;
2625

2726
public readonly SNI.SNIPacket ManagedPacket;
27+
#endif
2828
public readonly SNIPacket NativePacket;
2929
public readonly IntPtr NativePointer;
3030
public readonly int Type;
3131

32+
#if NET
3233
private PacketHandle(IntPtr nativePointer, SNIPacket nativePacket, SNI.SNIPacket managedPacket, int type)
3334
{
3435
Type = type;
3536
ManagedPacket = managedPacket;
3637
NativePointer = nativePointer;
3738
NativePacket = nativePacket;
3839
}
40+
#else
41+
private PacketHandle(IntPtr nativePointer, SNIPacket nativePacket, int type)
42+
{
43+
Type = type;
44+
NativePointer = nativePointer;
45+
NativePacket = nativePacket;
46+
}
47+
#endif
3948

49+
#if NET
4050
public static PacketHandle FromManagedPacket(SNI.SNIPacket managedPacket) =>
4151
new PacketHandle(default, default, managedPacket, ManagedPacketType);
4252

@@ -45,9 +55,12 @@ public static PacketHandle FromNativePointer(IntPtr nativePointer) =>
4555

4656
public static PacketHandle FromNativePacket(SNIPacket nativePacket) =>
4757
new PacketHandle(default, nativePacket, default, NativePacketType);
58+
#else
59+
public static PacketHandle FromNativePointer(IntPtr nativePointer) =>
60+
new PacketHandle(nativePointer, default, NativePointerType);
4861

49-
62+
public static PacketHandle FromNativePacket(SNIPacket nativePacket) =>
63+
new PacketHandle(default, nativePacket, NativePacketType);
64+
#endif
5065
}
5166
}
52-
53-
#endif

0 commit comments

Comments
 (0)