-
Notifications
You must be signed in to change notification settings - Fork 321
Introduce app context switch for setting MSF=true by default #3841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new app context switch Switch.Microsoft.Data.SqlClient.EnableMSFByDefaultInConnString that allows applications to change the default value of the MultiSubnetFailover connection string property from false to true. This enables parallel IP connection attempts by default in multi-subnet environments, which can improve connection times for Always On availability groups.
Key changes:
- Implements the app context switch following established patterns in the codebase
- Changes
DbConnectionStringDefaults.MultiSubnetFailoverfrom a const to a property that reads the switch value - Adds comprehensive unit tests covering various scenarios including explicit overrides and FailoverPartner validation
- Properly integrates with the existing test infrastructure for app context switch testing
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs |
Adds the new app context switch constant, static field, and public property with XML documentation |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/ConnectionString/DbConnectionStringDefaults.cs |
Changes MultiSubnetFailover from const to property that reads from the app context switch |
src/Microsoft.Data.SqlClient/tests/Common/LocalAppContextSwitchesHelper.cs |
Adds test helper infrastructure to manipulate and restore the switch state for testing |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/SqlConnectionStringTest.cs |
Adds comprehensive unit tests for the new switch behavior including edge cases |
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/LocalAppContextSwitchesTest.cs |
Updates default value assertion test to include the new switch |
src/Microsoft.Data.SqlClient/tests/Common/LocalAppContextSwitchesHelper.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
Outdated
Show resolved
Hide resolved
...Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/SqlConnectionStringTest.cs
Outdated
Show resolved
Hide resolved
...Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/SqlConnectionStringTest.cs
Outdated
Show resolved
Hide resolved
...soft.Data.SqlClient/src/Microsoft/Data/Common/ConnectionString/DbConnectionStringDefaults.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
Show resolved
Hide resolved
…by default (#3851) This commit introduces app context switch for setting MultiSubnetFailover=true by default in connection string when the app context switch is set to true. The default value of the context switch is false.
… by default (#3852) This commit introduces app context switch EnableMultiSubnetFailoverByDefault to set MultiSubnetFailover=true in connection string by default when the app context switch is set to true. The default value of this context switch is set to false.
Description
This PR introduces new app context switch
Switch.Microsoft.Data.SqlClient.EnableMultiSubnetFailoverByDefaultto setMultiSubnetFailover=true by default in connection string.Usage
In application
Or In config file
runtimeconfig.json{ "configProperties": { "Switch.Microsoft.Data.SqlClient.EnableMultiSubnetFailoverByDefault": true } }Or in App.Config
Issues
AB#40809
Testing
Enhanced
LocalAppContextSwitchesTest.csto test new app context switch.Added unit tests in
SqlConnectionStringTest.csGuidelines
Please review the contribution guidelines before submitting a pull request: