Skip to content

Commit 73aa0da

Browse files
authored
Combine: Move SqlEnvChange to shared and sync usage (#1525)
1 parent a43348b commit 73aa0da

File tree

10 files changed

+289
-274
lines changed

10 files changed

+289
-274
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@
388388
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlEnums.cs">
389389
<Link>Microsoft\Data\SqlClient\SqlEnums.cs</Link>
390390
</Compile>
391+
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlEnvChange.cs">
392+
<Link>Microsoft\Data\SqlClient\SqlEnvChange.cs</Link>
393+
</Compile>
391394
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlError.cs">
392395
<Link>Microsoft\Data\SqlClient\SqlError.cs</Link>
393396
</Compile>

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

+17-17
Original file line numberDiff line numberDiff line change
@@ -1994,36 +1994,36 @@ internal bool IgnoreEnvChange
19941994
internal void OnEnvChange(SqlEnvChange rec)
19951995
{
19961996
Debug.Assert(!IgnoreEnvChange, "This function should not be called if IgnoreEnvChange is set!");
1997-
switch (rec.type)
1997+
switch (rec._type)
19981998
{
19991999
case TdsEnums.ENV_DATABASE:
20002000
// If connection is not open and recovery is not in progress, store the server value as the original.
20012001
if (!_fConnectionOpen && _recoverySessionData == null)
20022002
{
2003-
_originalDatabase = rec.newValue;
2003+
_originalDatabase = rec._newValue;
20042004
}
20052005

2006-
CurrentDatabase = rec.newValue;
2006+
CurrentDatabase = rec._newValue;
20072007
break;
20082008

20092009
case TdsEnums.ENV_LANG:
20102010
// If connection is not open and recovery is not in progress, store the server value as the original.
20112011
if (!_fConnectionOpen && _recoverySessionData == null)
20122012
{
2013-
_originalLanguage = rec.newValue;
2013+
_originalLanguage = rec._newValue;
20142014
}
20152015

2016-
_currentLanguage = rec.newValue;
2016+
_currentLanguage = rec._newValue;
20172017
break;
20182018

20192019
case TdsEnums.ENV_PACKETSIZE:
2020-
_currentPacketSize = int.Parse(rec.newValue, CultureInfo.InvariantCulture);
2020+
_currentPacketSize = int.Parse(rec._newValue, CultureInfo.InvariantCulture);
20212021
break;
20222022

20232023
case TdsEnums.ENV_COLLATION:
20242024
if (_currentSessionData != null)
20252025
{
2026-
_currentSessionData._collation = rec.newCollation;
2026+
_currentSessionData._collation = rec._newCollation;
20272027
}
20282028
break;
20292029

@@ -2043,20 +2043,20 @@ internal void OnEnvChange(SqlEnvChange rec)
20432043
{
20442044
throw SQL.ROR_FailoverNotSupportedServer(this);
20452045
}
2046-
_currentFailoverPartner = rec.newValue;
2046+
_currentFailoverPartner = rec._newValue;
20472047
break;
20482048

20492049
case TdsEnums.ENV_PROMOTETRANSACTION:
2050-
byte[] dtcToken = null;
2051-
if (rec.newBinRented)
2050+
byte[] dtcToken;
2051+
if (rec._newBinRented)
20522052
{
2053-
dtcToken = new byte[rec.newLength];
2054-
Buffer.BlockCopy(rec.newBinValue, 0, dtcToken, 0, dtcToken.Length);
2053+
dtcToken = new byte[rec._newLength];
2054+
Buffer.BlockCopy(rec._newBinValue, 0, dtcToken, 0, dtcToken.Length);
20552055
}
20562056
else
20572057
{
2058-
dtcToken = rec.newBinValue;
2059-
rec.newBinValue = null;
2058+
dtcToken = rec._newBinValue;
2059+
rec._newBinValue = null;
20602060
}
20612061
PromotedDTCToken = dtcToken;
20622062
break;
@@ -2077,16 +2077,16 @@ internal void OnEnvChange(SqlEnvChange rec)
20772077
break;
20782078

20792079
case TdsEnums.ENV_USERINSTANCE:
2080-
_instanceName = rec.newValue;
2080+
_instanceName = rec._newValue;
20812081
break;
20822082

20832083
case TdsEnums.ENV_ROUTING:
20842084
SqlClientEventSource.Log.TryAdvancedTraceEvent("<sc.SqlInternalConnectionTds.OnEnvChange|ADV> {0}, Received routing info", ObjectID);
2085-
if (string.IsNullOrEmpty(rec.newRoutingInfo.ServerName) || rec.newRoutingInfo.Protocol != 0 || rec.newRoutingInfo.Port == 0)
2085+
if (string.IsNullOrEmpty(rec._newRoutingInfo.ServerName) || rec._newRoutingInfo.Protocol != 0 || rec._newRoutingInfo.Port == 0)
20862086
{
20872087
throw SQL.ROR_InvalidRoutingInfo(this);
20882088
}
2089-
RoutingInfo = rec.newRoutingInfo;
2089+
RoutingInfo = rec._newRoutingInfo;
20902090
break;
20912091

20922092
default:

0 commit comments

Comments
 (0)