Skip to content

Commit 75d5277

Browse files
authored
Merge | SessionHandle, TdsParserStateObject (#3341)
* Merge identical TdsParserStateObject methods * Misc. minor cleanup and merge * Merge SessionHandle * Merge Status, SessionId, SessionHandle properties
1 parent feec5a7 commit 75d5277

File tree

8 files changed

+718
-1354
lines changed

8 files changed

+718
-1354
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
@@ -881,8 +881,8 @@
881881
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\PacketHandle.netcore.Windows.cs">
882882
<Link>Microsoft\Data\SqlClient\PacketHandle.netcore.Windows.cs</Link>
883883
</Compile>
884-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SessionHandle.netcore.Windows.cs">
885-
<Link>Microsoft\Data\SqlClient\SessionHandle.netcore.Windows.cs</Link>
884+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SessionHandle.Windows.cs">
885+
<Link>Microsoft\Data\SqlClient\SessionHandle.Windows.cs</Link>
886886
</Compile>
887887
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Windows.cs">
888888
<Link>Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Windows.cs</Link>

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs

Lines changed: 6 additions & 661 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,9 @@
609609
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlSer.cs">
610610
<Link>Microsoft\Data\SqlClient\Server\SqlSer.cs</Link>
611611
</Compile>
612+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SessionHandle.Windows.cs">
613+
<Link>Microsoft\Data\SqlClient\SessionHandle.Windows.cs</Link>
614+
</Compile>
612615
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SignatureVerificationCache.cs">
613616
<Link>Microsoft\Data\SqlClient\SignatureVerificationCache.cs</Link>
614617
</Compile>

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObject.netfx.cs

Lines changed: 15 additions & 680 deletions
Large diffs are not rendered by default.

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ internal TdsParserStateObjectNative(TdsParser parser)
1919
{
2020
}
2121

22+
////////////////
23+
// Properties //
24+
////////////////
25+
26+
internal override uint Status => _sessionHandle != null ? _sessionHandle.Status : TdsEnums.SNI_UNINITIALIZED;
27+
28+
internal override SessionHandle SessionHandle => SessionHandle.FromNativeHandle(_sessionHandle);
29+
30+
internal override Guid? SessionId => default;
31+
2232
internal override uint SniGetConnectionId(ref Guid clientConnectionId)
2333
=> SniNativeWrapper.SniGetConnectionId(Handle, ref clientConnectionId);
2434

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

Lines changed: 14 additions & 6 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
namespace Microsoft.Data.SqlClient
86
{
97
// this structure is used for transporting packet handle references between the TdsParserStateObject
@@ -16,14 +14,16 @@ namespace Microsoft.Data.SqlClient
1614

1715
internal readonly ref struct SessionHandle
1816
{
17+
#if NET
1918
public const int NativeHandleType = 1;
2019
public const int ManagedHandleType = 2;
2120

21+
public readonly int Type;
2222
public readonly SNI.SNIHandle ManagedHandle;
23+
#endif
2324
public readonly SNIHandle NativeHandle;
2425

25-
public readonly int Type;
26-
26+
#if NET
2727
public SessionHandle(SNI.SNIHandle managedHandle, SNIHandle nativeHandle, int type)
2828
{
2929
Type = type;
@@ -36,7 +36,15 @@ public SessionHandle(SNI.SNIHandle managedHandle, SNIHandle nativeHandle, int ty
3636
public static SessionHandle FromManagedSession(SNI.SNIHandle managedSessionHandle) => new SessionHandle(managedSessionHandle, default, ManagedHandleType);
3737

3838
public static SessionHandle FromNativeHandle(SNIHandle nativeSessionHandle) => new SessionHandle(default, nativeSessionHandle, NativeHandleType);
39-
}
40-
}
39+
#else
40+
public SessionHandle(SNIHandle nativeHandle)
41+
{
42+
NativeHandle = nativeHandle;
43+
}
44+
45+
public bool IsNull => NativeHandle is null;
4146

47+
public static SessionHandle FromNativeHandle(SNIHandle nativeSessionHandle) => new SessionHandle(nativeSessionHandle);
4248
#endif
49+
}
50+
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netcore.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ internal readonly ref struct SessionHandle
1919
public const int NativeHandleType = 1;
2020
public const int ManagedHandleType = 2;
2121

22-
public readonly SNI.SNIHandle ManagedHandle;
2322
public readonly int Type;
23+
public readonly SNI.SNIHandle ManagedHandle;
2424

2525
public SessionHandle(SNI.SNIHandle managedHandle, int type)
2626
{

0 commit comments

Comments
 (0)