Skip to content

Commit 3fe496c

Browse files
Revert default value of UseMinimumLoginTimeout context switch to 'true' (#2419)
* add test for bug * change default value of UseMinimumLoginTimeout back to 'true' * Update src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs --------- Co-authored-by: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com>
1 parent 22ac587 commit 3fe496c

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public static bool UseMinimumLoginTimeout
167167
{
168168
if (s_useMinimumLoginTimeout == Tristate.NotInitialized)
169169
{
170-
if (AppContext.TryGetSwitch(UseMinimumLoginTimeoutString, out bool returnedValue) && returnedValue)
170+
if (!AppContext.TryGetSwitch(UseMinimumLoginTimeoutString, out bool returnedValue) || returnedValue)
171171
{
172172
s_useMinimumLoginTimeout = Tristate.True;
173173
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.Reflection;
6+
using Xunit;
7+
8+
namespace Microsoft.Data.SqlClient.Tests
9+
{
10+
public class LocalAppContextSwitchesTests
11+
{
12+
[Theory]
13+
[InlineData("SuppressInsecureTLSWarning", false)]
14+
[InlineData("LegacyRowVersionNullBehavior", false)]
15+
[InlineData("MakeReadAsyncBlocking", false)]
16+
[InlineData("UseMinimumLoginTimeout", true)]
17+
public void DefaultSwitchValue(string property, bool expectedDefaultValue)
18+
{
19+
var switchesType = typeof(SqlCommand).Assembly.GetType("Microsoft.Data.SqlClient.LocalAppContextSwitches");
20+
21+
var switchValue = (bool)switchesType.GetProperty(property, BindingFlags.Public | BindingFlags.Static).GetValue(null);
22+
23+
Assert.Equal(expectedDefaultValue, switchValue);
24+
}
25+
}
26+
}

src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<Compile Include="SqlBufferTests.cs" />
3434
<Compile Include="SqlClientLoggerTest.cs" />
3535
<Compile Include="SqlCommandSetTest.cs" />
36+
<Compile Include="LocalAppContextSwitchesTests.cs" />
3637
<Compile Include="SqlConfigurableRetryLogicTest.cs" />
3738
<Compile Include="SqlCommandBuilderTest.cs" />
3839
<Compile Include="SqlBulkCopyTest.cs" />

0 commit comments

Comments
 (0)