From e90a5e8e65942edd32e7dd833afc3a638b39e090 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Mon, 24 Mar 2025 13:49:20 -0500 Subject: [PATCH 1/4] Move files to common project --- .../Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs} | 0 .../Microsoft/Data/SqlClient/PacketHandle.netcore.Windows.cs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/Microsoft.Data.SqlClient/{netcore/src/Microsoft/Data/SqlClient/PacketHandle.Unix.cs => src/Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs} (100%) rename src/Microsoft.Data.SqlClient/{netcore/src/Microsoft/Data/SqlClient/PacketHandle.Windows.cs => src/Microsoft/Data/SqlClient/PacketHandle.netcore.Windows.cs} (100%) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/PacketHandle.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/PacketHandle.Unix.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/PacketHandle.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Windows.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/PacketHandle.Windows.cs rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Windows.cs From 86835d3ec7f032b913006adba287360e20e44a99 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Mon, 24 Mar 2025 13:57:32 -0500 Subject: [PATCH 2/4] Wrapping files in #if NET and doing some very light formatting changes --- .../SqlClient/PacketHandle.netcore.Unix.cs | 19 +++++++---- .../SqlClient/PacketHandle.netcore.Windows.cs | 32 ++++++++++++------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs index 63ba0014c4..3ec188d79d 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs @@ -2,15 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; +#if NET namespace Microsoft.Data.SqlClient { - // this structure is used for transporting packet handle references between the TdsParserStateObject - // base class and Managed or Native implementations. - // It prevents the native IntPtr type from being boxed and prevents the need to cast from object which loses compile time type safety - // It carries type information so that assertions about the type of handle can be made in the implemented abstract methods - // it is a ref struct so that it can only be used to transport the handles and not store them + // This structure is used for transporting packet handle references between the + // TdsParserStateObject base class and Managed or Native implementations. + // It prevents the native IntPtr type from being boxed and prevents the need to cast from + // object which loses compile time type safety. + // It carries type information so that assertions about the type of handle can be made in the + // implemented abstract methods. + // It is a ref struct so that it can only be used to transport the handles and not store them // N.B. If you change this type you must also change the version for the other platform @@ -29,6 +31,9 @@ private PacketHandle(SNI.SNIPacket managedPacket, int type) ManagedPacket = managedPacket; } - public static PacketHandle FromManagedPacket(SNI.SNIPacket managedPacket) => new PacketHandle(managedPacket, ManagedPacketType); + public static PacketHandle FromManagedPacket(SNI.SNIPacket managedPacket) => + new PacketHandle(managedPacket, ManagedPacketType); } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Windows.cs index 15c2ae58eb..aca8292100 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Windows.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Windows.cs @@ -2,15 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NET + using System; namespace Microsoft.Data.SqlClient { - // this structure is used for transporting packet handle references between the TdsParserStateObject - // base class and Managed or Native implementations. - // It prevents the native IntPtr type from being boxed and prevents the need to cast from object which loses compile time type safety - // It carries type information so that assertions about the type of handle can be made in the implemented abstract methods - // it is a ref struct so that it can only be used to transport the handles and not store them + // This structure is used for transporting packet handle references between the + // TdsParserStateObject base class and Managed or Native implementations. + // It prevents the native IntPtr type from being boxed and prevents the need to cast from + // object which loses compile time type safety. + // It carries type information so that assertions about the type of handle can be made in the + // implemented abstract methods. + // It is a ref struct so that it can only be used to transport the handles and not store them // N.B. If you change this type you must also change the version for the other platform @@ -20,10 +24,9 @@ internal readonly ref struct PacketHandle public const int NativePacketType = 2; public const int ManagedPacketType = 3; - public readonly IntPtr NativePointer; - public readonly SNIPacket NativePacket; - public readonly SNI.SNIPacket ManagedPacket; + public readonly SNIPacket NativePacket; + public readonly IntPtr NativePointer; public readonly int Type; private PacketHandle(IntPtr nativePointer, SNIPacket nativePacket, SNI.SNIPacket managedPacket, int type) @@ -34,12 +37,17 @@ private PacketHandle(IntPtr nativePointer, SNIPacket nativePacket, SNI.SNIPacket NativePacket = nativePacket; } - public static PacketHandle FromManagedPacket(SNI.SNIPacket managedPacket) => new PacketHandle(default, default, managedPacket, ManagedPacketType); + public static PacketHandle FromManagedPacket(SNI.SNIPacket managedPacket) => + new PacketHandle(default, default, managedPacket, ManagedPacketType); - public static PacketHandle FromNativePointer(IntPtr nativePointer) => new PacketHandle(nativePointer, default, default, NativePointerType); + public static PacketHandle FromNativePointer(IntPtr nativePointer) => + new PacketHandle(nativePointer, default, default, NativePointerType); - public static PacketHandle FromNativePacket(SNIPacket nativePacket) => new PacketHandle(default, nativePacket, default, NativePacketType); + public static PacketHandle FromNativePacket(SNIPacket nativePacket) => + new PacketHandle(default, nativePacket, default, NativePacketType); } -} \ No newline at end of file +} + +#endif From 906564e1b2db99f12292c03550ef1c049d5936ac Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Mon, 24 Mar 2025 14:03:26 -0500 Subject: [PATCH 3/4] Changing links to file in csproj --- .../netcore/src/Microsoft.Data.SqlClient.csproj | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj index bb77ffba3e..ba7e89c0e2 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -848,6 +848,9 @@ Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs + + Microsoft\Data\SqlClient\PacketHandle.netcore.Windows.cs + Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Windows.cs @@ -867,7 +870,6 @@ Microsoft\Data\SqlTypes\SqlFileStream.Windows.cs - @@ -886,9 +888,11 @@ Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Unix.cs + + Microsoft\Data\SqlClient\PacketHandle.netcore.Unix.cs + - From 62706fed409aaa7592ef9690d08c881a5465517b Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Tue, 25 Mar 2025 15:13:13 -0500 Subject: [PATCH 4/4] Fix copy/paste mistake --- .../netcore/src/Microsoft.Data.SqlClient.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj index ba7e89c0e2..c4020a797d 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -888,7 +888,7 @@ Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Unix.cs - + Microsoft\Data\SqlClient\PacketHandle.netcore.Unix.cs