Skip to content

Cleanup | Remove dead code paths and Regexes from SqlConnectionOptions - #4544

Open
edwardneal wants to merge 11 commits into
dotnet:mainfrom
edwardneal:cleanup/sqlconnectionoptions-regex
Open

Cleanup | Remove dead code paths and Regexes from SqlConnectionOptions#4544
edwardneal wants to merge 11 commits into
dotnet:mainfrom
edwardneal:cleanup/sqlconnectionoptions-regex

Conversation

@edwardneal

Copy link
Copy Markdown
Contributor

Description

SqlConnectionOptions has a handful of code paths which were inherited from the need to write a generic parser for ODBC connection strings. These code paths are no longer used, so this PR just cleans them up.

In the case of GetKeyValuePair, there are a few code paths which could never be called, and codecov demonstrates this. In the other cases, they were criteria which would always be met.

One interesting point emerges from this: SqlConnectionOptions has four statically-initialised compiled Regex instances. One of them is completely unused, one is only used by netfx code and two are only used in Debug builds. I've cleaned these up, so the static constructor for the class sheds some load.

This is cleanup work which has an incidental performance benefit - it doesn't have a benchmark attached to it, and I couldn't see any results because we're dealing with static constructors.

For review, this can move commit-by-commit.

Issues

None.

Testing

All unit tests for connection string parsing continue to pass. All changes can be statically verified.

ConnectionStringRegexOdbc was rendered unused by the previous commit.
This helper uses managed code rather than the the s_connectionStringValidKeyRegex Regex, but retains a Debug-only assertion.
These are now only used in debug builds
These are only used by netfx codepaths, and do not need to be instantiated on netcore
BraceQuoteValue and BraceQuoteValueQuote were only accessible from one another, and when useOdbcRules was true.
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

1 participant