Skip to content

Commit 09b8b16

Browse files
Minor Touch-ups + consistent naming (#2724)
1 parent 7c03078 commit 09b8b16

File tree

9 files changed

+48
-77
lines changed

9 files changed

+48
-77
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,8 @@
946946
<Compile Include="Microsoft\Data\SqlClientX\Handlers\NoSuitableHandlerFoundException.cs" />
947947
<Compile Include="Microsoft\Data\SqlClientX\Handlers\ReturningHandlerChain.cs" />
948948
<Compile Include="Microsoft\Data\SqlClientX\Handlers\ReturningHandlerChainExceptionBehavior.cs" />
949-
<Compile Include="Microsoft\Data\SqlClientX\Handlers\HandlerOrchestrator.cs" />
950-
<Compile Include="Microsoft\Data\SqlClientX\Handlers\InternalConnectionContext.cs" />
951-
<Compile Include="Microsoft\Data\SqlClientX\Handlers\SqlUtilsX.cs" />
949+
<Compile Include="Microsoft\Data\SqlClientX\Handlers\Connection\ConnectionHandlerOrchestrator.cs" />
950+
<Compile Include="Microsoft\Data\SqlClientX\SqlUtilsX.cs" />
952951
<Compile Include="Microsoft\Data\SqlClientX\IO\ITdsReadStream.cs" />
953952
<Compile Include="Microsoft\Data\SqlClientX\IO\ITdsStream.cs" />
954953
<Compile Include="Microsoft\Data\SqlClientX\IO\ITdsWriteStream.cs" />

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/Handlers/Connection/ConnectionHandlerContext.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
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.
4+
45
using System;
56
using System.Collections.Generic;
67
using System.IO;
@@ -58,12 +59,12 @@ internal class ConnectionHandlerContext : HandlerRequest, ICloneable
5859
/// Whether the connection is capable of MARS
5960
/// This is negotiated after pre-login.
6061
/// </summary>
61-
public bool MarsCapable { get; internal set; }
62+
public bool IsMarsCapable { get; internal set; }
6263

6364
/// <summary>
6465
/// Indicates if fed auth needed for this connection.
6566
/// </summary>
66-
public bool FedAuthRequired { get; internal set; }
67+
public bool IsFedAuthRequired { get; internal set; }
6768

6869
/// <summary>
6970
/// The access token in bytes.
@@ -110,8 +111,8 @@ public object Clone()
110111
SslStream = this.SslStream,
111112
SslOverTdsStream = this.SslOverTdsStream,
112113
TdsStream = this.TdsStream,
113-
MarsCapable = this.MarsCapable,
114-
FedAuthRequired = this.FedAuthRequired,
114+
IsMarsCapable = this.IsMarsCapable,
115+
IsFedAuthRequired = this.IsFedAuthRequired,
115116
AccessTokenInBytes = this.AccessTokenInBytes,
116117
ServerInfo = this.ServerInfo,
117118
ErrorCollection = this.ErrorCollection,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
8+
namespace Microsoft.Data.SqlClientX.Handlers.Connection
9+
{
10+
internal static class ConnectionHandlerOrchestrator
11+
{
12+
/// <summary>
13+
/// Initiates the pre-defined chain of handlers
14+
/// </summary>
15+
/// <param name="context">Connection Handler Context</param>
16+
/// <param name="isAsync">Whether the calling method is executing asynchronously.</param>
17+
/// <param name="ct">Cancellation Token</param>
18+
/// <returns></returns>
19+
public static ValueTask ProcessRequestAsync(ConnectionHandlerContext context, bool isAsync, CancellationToken ct)
20+
=> new DataSourceParsingHandler()
21+
{
22+
NextHandler = new TransportCreationHandler()
23+
{
24+
NextHandler = new PreloginHandler()
25+
}
26+
}.Handle(context, isAsync, ct);
27+
}
28+
}

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/Handlers/Connection/DataSourceParsingHandler.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Microsoft.Data.SqlClientX.Handlers.Connection
1515
internal class DataSourceParsingHandler : ContextHandler<ConnectionHandlerContext>
1616
{
1717
/// <inheritdoc />
18-
public override async ValueTask Handle(ConnectionHandlerContext request, bool isAsync, CancellationToken ct)
18+
public override ValueTask Handle(ConnectionHandlerContext request, bool isAsync, CancellationToken ct)
1919
{
2020
ServerInfo serverInfo = request.ServerInfo;
2121
string fullServerName = serverInfo.ExtendedServerName;
@@ -28,7 +28,7 @@ public override async ValueTask Handle(ConnectionHandlerContext request, bool is
2828
collection.Add(new SqlError(0,0,TdsEnums.FATAL_ERROR_CLASS, null, StringsHelper.GetString("LocalDB_UnobtainableMessage"), null, 0));
2929
throw SqlException.CreateException(collection, null);
3030
}
31-
31+
3232
// If a localDB Data source is available, we need to use it.
3333
fullServerName = localDBDataSource ?? fullServerName;
3434
DataSource details = DataSource.ParseServerName(fullServerName);
@@ -39,13 +39,15 @@ public override async ValueTask Handle(ConnectionHandlerContext request, bool is
3939
collection.Add(new SqlError(0, 0, TdsEnums.FATAL_ERROR_CLASS, null, StringsHelper.GetString("LocalDB_UnobtainableMessage"), null, 0));
4040
throw SqlException.CreateException(collection, null);
4141
}
42-
42+
4343
request.DataSource = details;
44-
44+
4545
if (NextHandler is not null)
4646
{
47-
await NextHandler.Handle(request, isAsync, ct).ConfigureAwait(false);
47+
return NextHandler.Handle(request, isAsync, ct);
4848
}
49+
50+
return ValueTask.CompletedTask;
4951
}
5052

5153
//TODO: Refactor function for better handling of error flag and return params
@@ -72,7 +74,7 @@ private static string GetLocalDBDataSource(string fullServerName, out bool error
7274
return null;
7375
}
7476
}
75-
77+
7678
error = false;
7779
return localDBConnectionString;
7880
}

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/Handlers/Connection/PreloginHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal class PreloginHandler : ContextHandler<ConnectionHandlerContext>
3232
private readonly PreloginSubHandlerBuilder _subHandlerChainBuilder;
3333

3434
/// <summary>
35-
/// Paraemter-less constructor which creates an authenticator for TLS.
35+
/// Parameter-less constructor which creates an authenticator for TLS.
3636
/// </summary>
3737
public PreloginHandler() : this(new TlsAuthenticator(), new PreloginSubHandlerBuilder())
3838
{

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/Handlers/Connection/PreloginSubHandlers/PreloginPacketHandler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public async ValueTask Handle(PreloginHandlerContext context, bool isAsync, Canc
7575
/// <returns></returns>
7676
private async Task ReadPreloginResponse(PreloginHandlerContext context, bool isAsync, CancellationToken ct)
7777
{
78-
context.ConnectionContext.MarsCapable = context.ConnectionContext.ConnectionString.MARS; // Assign default value
79-
context.ConnectionContext.FedAuthRequired = false;
78+
context.ConnectionContext.IsMarsCapable = context.ConnectionContext.ConnectionString.MARS; // Assign default value
79+
context.ConnectionContext.IsFedAuthRequired = false;
8080

8181
TdsStream tdsStream = context.ConnectionContext.TdsStream;
8282

@@ -192,7 +192,7 @@ private async Task ReadPreloginResponse(PreloginHandlerContext context, bool isA
192192
payloadOffset = BinaryPrimitives.ReadUInt16BigEndian(preloginPayload.AsSpan(offset, 2));
193193
offset += PAYLOAD_OFFSET_AND_LENGTH_SIZE_IN_BYTES;
194194

195-
context.ConnectionContext.MarsCapable = (preloginPayload[payloadOffset] != 0);
195+
context.ConnectionContext.IsMarsCapable = (preloginPayload[payloadOffset] != 0);
196196
Debug.Assert(preloginPayload[payloadOffset] == 0 || preloginPayload[payloadOffset] == 1, "Value for Mars PreLoginHandshake option not equal to 1 or 0!");
197197
break;
198198

@@ -220,7 +220,7 @@ private async Task ReadPreloginResponse(PreloginHandlerContext context, bool isA
220220
&& context.ConnectionContext.ConnectionString.Authentication != SqlAuthenticationMethod.NotSpecified)
221221
|| context.ConnectionContext.AccessTokenInBytes != null || context.ConnectionContext.AccessTokenCallback != null)
222222
{
223-
context.ConnectionContext.FedAuthRequired = preloginPayload[payloadOffset] == 0x01;
223+
context.ConnectionContext.IsFedAuthRequired = preloginPayload[payloadOffset] == 0x01;
224224
}
225225
break;
226226

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/Handlers/HandlerOrchestrator.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/Handlers/InternalConnectionContext.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/Handlers/SqlUtilsX.cs renamed to src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/SqlUtilsX.cs

File renamed without changes.

0 commit comments

Comments
 (0)