Skip to content

Commit bc59f58

Browse files
benrr101Ben Russell
andauthored
Cleanup | LocalDbApi (#3182)
* Moving LocalDbApi to the localdb folder * Cleanup for localdbapi * Applying the same cleanup to the Unix LocalDbApi implementation --------- Co-authored-by: Ben Russell <ben@holycrapitsbenrussell>
1 parent c5952ae commit bc59f58

File tree

10 files changed

+191
-147
lines changed

10 files changed

+191
-147
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,8 @@
786786
<Compile Include="$(CommonSourceRoot)Microsoft\Data\Sql\SqlDataSourceEnumerator.Windows.cs">
787787
<Link>Microsoft\Data\Sql\SqlDataSourceEnumerator.Windows.cs</Link>
788788
</Compile>
789-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDBAPI.Windows.cs">
790-
<Link>Microsoft\Data\SqlClient\LocalDBAPI.Windows.cs</Link>
789+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs">
790+
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs</Link>
791791
</Compile>
792792
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Windows.cs">
793793
<Link>Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Windows.cs</Link>
@@ -824,8 +824,8 @@
824824
<Compile Include="$(CommonSourceRoot)Microsoft\Data\ProviderBase\DbConnectionPoolIdentity.Unix.cs">
825825
<Link>Microsoft\Data\ProviderBase\DbConnectionPoolIdentity.Unix.cs</Link>
826826
</Compile>
827-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDBAPI.Unix.cs">
828-
<Link>Microsoft\Data\SqlClient\LocalDBAPI.Unix.cs</Link>
827+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Unix.cs">
828+
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Unix.cs</Link>
829829
</Compile>
830830

831831
<Compile Include="Microsoft\Data\Sql\SqlDataSourceEnumerator.Unix.cs" />

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Microsoft.Data.ProviderBase;
2222
using Microsoft.Data.Sql;
2323
using Microsoft.Data.SqlClient.DataClassification;
24+
using Microsoft.Data.SqlClient.LocalDb;
2425
using Microsoft.Data.SqlClient.Server;
2526
using Microsoft.Data.SqlTypes;
2627

@@ -1557,7 +1558,7 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj)
15571558
// If its a LocalDB error, then nativeError actually contains a LocalDB-specific error code, not a win32 error code
15581559
if (details.sniErrorNumber == SniErrors.LocalDBErrorCode)
15591560
{
1560-
errorMessage += LocalDBAPI.GetLocalDBMessage((int)details.nativeError);
1561+
errorMessage += LocalDbApi.GetLocalDbMessage((int)details.nativeError);
15611562
win32ErrorCode = 0;
15621563
}
15631564
SqlClientEventSource.Log.TryAdvancedTraceEvent("<sc.TdsParser.ProcessSNIError |ERR|ADV > Extracting the latest exception from native SNI. errorMessage: {0}", errorMessage);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@
394394
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\EnclaveSessionCache.cs">
395395
<Link>Microsoft\Data\SqlClient\EnclaveSessionCache.cs</Link>
396396
</Compile>
397-
<Compile Include="$(CommonSourceROot)Microsoft\Data\SqlClient\LocalDBAPI.Windows.cs">
398-
<Link>Microsoft\Data\SqlClient\LocalDBAPI.Windows.cs</Link>
397+
<Compile Include="$(CommonSourceROot)Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs">
398+
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs</Link>
399399
</Compile>
400400
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\LocalDb\LocalDbConfigurationSection.netfx.cs">
401401
<Link>Microsoft\Data\SqlClient\LocalDb\LocalDbConfigurationSection.netfx.cs</Link>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using Microsoft.Data.Common;
2525
using Microsoft.Data.Sql;
2626
using Microsoft.Data.SqlClient.DataClassification;
27+
using Microsoft.Data.SqlClient.LocalDb;
2728
using Microsoft.Data.SqlClient.Server;
2829
using Microsoft.Data.SqlTypes;
2930
using Microsoft.SqlServer.Server;
@@ -418,7 +419,7 @@ internal void Connect(ServerInfo serverInfo,
418419
//Create LocalDB instance if necessary
419420
if (connHandler.ConnectionOptions.LocalDBInstance != null)
420421
{
421-
LocalDBAPI.CreateLocalDBInstance(connHandler.ConnectionOptions.LocalDBInstance);
422+
LocalDbApi.CreateLocalDbInstance(connHandler.ConnectionOptions.LocalDBInstance);
422423
if (encrypt == SqlConnectionEncryptOption.Mandatory)
423424
{
424425
// Encryption is not supported on SQL Local DB - disable it for current session.
@@ -1678,7 +1679,7 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj)
16781679
// If its a LocalDB error, then nativeError actually contains a LocalDB-specific error code, not a win32 error code
16791680
if (sniError.sniError == SniErrors.LocalDBErrorCode)
16801681
{
1681-
errorMessage += LocalDBAPI.GetLocalDBMessage((int)sniError.nativeError);
1682+
errorMessage += LocalDbApi.GetLocalDbMessage((int)sniError.nativeError);
16821683
win32ErrorCode = 0;
16831684
}
16841685
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDBAPI.Unix.cs renamed to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.Unix.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
using System;
66

7-
namespace Microsoft.Data
7+
namespace Microsoft.Data.SqlClient.LocalDb
88
{
9-
internal static partial class LocalDBAPI
9+
internal static class LocalDbApi
1010
{
1111
internal static string GetLocalDbInstanceNameFromServerName(string serverName) =>
1212
null;
1313

14-
internal static string GetLocalDBMessage(int hrCode) =>
14+
internal static string GetLocalDbMessage(int hrCode) =>
1515
throw new PlatformNotSupportedException(Strings.LocalDBNotSupported); // LocalDB is not available for Unix and hence it cannot be supported.
1616
}
1717
}

0 commit comments

Comments
 (0)