Skip to content

Commit 414f016

Browse files
authored
Merge | PacketHandle.*.cs (#3241)
* Move files to common project * Wrapping files in #if NET and doing some very light formatting changes * Changing links to file in csproj * Fix copy/paste mistake
1 parent ebcc63a commit 414f016

File tree

3 files changed

+38
-21
lines changed

3 files changed

+38
-21
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,9 @@
848848
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs">
849849
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs</Link>
850850
</Compile>
851+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\PacketHandle.netcore.Windows.cs">
852+
<Link>Microsoft\Data\SqlClient\PacketHandle.netcore.Windows.cs</Link>
853+
</Compile>
851854
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Windows.cs">
852855
<Link>Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Windows.cs</Link>
853856
</Compile>
@@ -867,7 +870,6 @@
867870
<Link>Microsoft\Data\SqlTypes\SqlFileStream.Windows.cs</Link>
868871
</Compile>
869872

870-
<Compile Include="Microsoft\Data\SqlClient\PacketHandle.Windows.cs" />
871873
<Compile Include="Microsoft\Data\SqlClient\SessionHandle.Windows.cs" />
872874
<Compile Include="Microsoft\Data\SqlClient\SNI\LocalDB.Windows.cs" />
873875
<Compile Include="Microsoft\Data\SqlClient\TdsParser.Windows.cs" />
@@ -886,9 +888,11 @@
886888
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Unix.cs">
887889
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Unix.cs</Link>
888890
</Compile>
891+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\PacketHandle.netcore.Unix.cs">
892+
<Link>Microsoft\Data\SqlClient\PacketHandle.netcore.Unix.cs</Link>
893+
</Compile>
889894

890895
<Compile Include="Microsoft\Data\Sql\SqlDataSourceEnumerator.Unix.cs" />
891-
<Compile Include="Microsoft\Data\SqlClient\PacketHandle.Unix.cs" />
892896
<Compile Include="Microsoft\Data\SqlClient\SessionHandle.Unix.cs" />
893897
<Compile Include="Microsoft\Data\SqlClient\SNI\LocalDB.Unix.cs" />
894898
<Compile Include="Microsoft\Data\SqlClient\SqlColumnEncryptionCertificateStoreProvider.Unix.cs" />

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
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-
using System;
5+
#if NET
66

77
namespace Microsoft.Data.SqlClient
88
{
9-
// this structure is used for transporting packet handle references between the TdsParserStateObject
10-
// base class and Managed or Native implementations.
11-
// It prevents the native IntPtr type from being boxed and prevents the need to cast from object which loses compile time type safety
12-
// It carries type information so that assertions about the type of handle can be made in the implemented abstract methods
13-
// it is a ref struct so that it can only be used to transport the handles and not store them
9+
// This structure is used for transporting packet handle references between the
10+
// TdsParserStateObject base class and Managed or Native implementations.
11+
// It prevents the native IntPtr type from being boxed and prevents the need to cast from
12+
// object which loses compile time type safety.
13+
// It carries type information so that assertions about the type of handle can be made in the
14+
// implemented abstract methods.
15+
// It is a ref struct so that it can only be used to transport the handles and not store them
1416

1517
// N.B. If you change this type you must also change the version for the other platform
1618

@@ -29,6 +31,9 @@ private PacketHandle(SNI.SNIPacket managedPacket, int type)
2931
ManagedPacket = managedPacket;
3032
}
3133

32-
public static PacketHandle FromManagedPacket(SNI.SNIPacket managedPacket) => new PacketHandle(managedPacket, ManagedPacketType);
34+
public static PacketHandle FromManagedPacket(SNI.SNIPacket managedPacket) =>
35+
new PacketHandle(managedPacket, ManagedPacketType);
3336
}
3437
}
38+
39+
#endif

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
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+
57
using System;
68

79
namespace Microsoft.Data.SqlClient
810
{
9-
// this structure is used for transporting packet handle references between the TdsParserStateObject
10-
// base class and Managed or Native implementations.
11-
// It prevents the native IntPtr type from being boxed and prevents the need to cast from object which loses compile time type safety
12-
// It carries type information so that assertions about the type of handle can be made in the implemented abstract methods
13-
// it is a ref struct so that it can only be used to transport the handles and not store them
11+
// This structure is used for transporting packet handle references between the
12+
// TdsParserStateObject base class and Managed or Native implementations.
13+
// It prevents the native IntPtr type from being boxed and prevents the need to cast from
14+
// object which loses compile time type safety.
15+
// It carries type information so that assertions about the type of handle can be made in the
16+
// implemented abstract methods.
17+
// It is a ref struct so that it can only be used to transport the handles and not store them
1418

1519
// N.B. If you change this type you must also change the version for the other platform
1620

@@ -20,10 +24,9 @@ internal readonly ref struct PacketHandle
2024
public const int NativePacketType = 2;
2125
public const int ManagedPacketType = 3;
2226

23-
public readonly IntPtr NativePointer;
24-
public readonly SNIPacket NativePacket;
25-
2627
public readonly SNI.SNIPacket ManagedPacket;
28+
public readonly SNIPacket NativePacket;
29+
public readonly IntPtr NativePointer;
2730
public readonly int Type;
2831

2932
private PacketHandle(IntPtr nativePointer, SNIPacket nativePacket, SNI.SNIPacket managedPacket, int type)
@@ -34,12 +37,17 @@ private PacketHandle(IntPtr nativePointer, SNIPacket nativePacket, SNI.SNIPacket
3437
NativePacket = nativePacket;
3538
}
3639

37-
public static PacketHandle FromManagedPacket(SNI.SNIPacket managedPacket) => new PacketHandle(default, default, managedPacket, ManagedPacketType);
40+
public static PacketHandle FromManagedPacket(SNI.SNIPacket managedPacket) =>
41+
new PacketHandle(default, default, managedPacket, ManagedPacketType);
3842

39-
public static PacketHandle FromNativePointer(IntPtr nativePointer) => new PacketHandle(nativePointer, default, default, NativePointerType);
43+
public static PacketHandle FromNativePointer(IntPtr nativePointer) =>
44+
new PacketHandle(nativePointer, default, default, NativePointerType);
4045

41-
public static PacketHandle FromNativePacket(SNIPacket nativePacket) => new PacketHandle(default, nativePacket, default, NativePacketType);
46+
public static PacketHandle FromNativePacket(SNIPacket nativePacket) =>
47+
new PacketHandle(default, nativePacket, default, NativePacketType);
4248

4349

4450
}
45-
}
51+
}
52+
53+
#endif

0 commit comments

Comments
 (0)