Skip to content

Commit

Permalink
Revert default value of UseMinimumLoginTimeout context switch to 'tru…
Browse files Browse the repository at this point in the history
…e' (#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>
  • Loading branch information
EamonHetherton and cheenamalhotra authored Nov 25, 2024
1 parent 22ac587 commit 3fe496c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public static bool UseMinimumLoginTimeout
{
if (s_useMinimumLoginTimeout == Tristate.NotInitialized)
{
if (AppContext.TryGetSwitch(UseMinimumLoginTimeoutString, out bool returnedValue) && returnedValue)
if (!AppContext.TryGetSwitch(UseMinimumLoginTimeoutString, out bool returnedValue) || returnedValue)
{
s_useMinimumLoginTimeout = Tristate.True;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Reflection;
using Xunit;

namespace Microsoft.Data.SqlClient.Tests
{
public class LocalAppContextSwitchesTests
{
[Theory]
[InlineData("SuppressInsecureTLSWarning", false)]
[InlineData("LegacyRowVersionNullBehavior", false)]
[InlineData("MakeReadAsyncBlocking", false)]
[InlineData("UseMinimumLoginTimeout", true)]
public void DefaultSwitchValue(string property, bool expectedDefaultValue)
{
var switchesType = typeof(SqlCommand).Assembly.GetType("Microsoft.Data.SqlClient.LocalAppContextSwitches");

var switchValue = (bool)switchesType.GetProperty(property, BindingFlags.Public | BindingFlags.Static).GetValue(null);

Assert.Equal(expectedDefaultValue, switchValue);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<Compile Include="SqlBufferTests.cs" />
<Compile Include="SqlClientLoggerTest.cs" />
<Compile Include="SqlCommandSetTest.cs" />
<Compile Include="LocalAppContextSwitchesTests.cs" />
<Compile Include="SqlConfigurableRetryLogicTest.cs" />
<Compile Include="SqlCommandBuilderTest.cs" />
<Compile Include="SqlBulkCopyTest.cs" />
Expand Down

0 comments on commit 3fe496c

Please sign in to comment.