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+
57using System ;
68
79namespace 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