Skip to content

Refactor TestDataConnectionSql into focused partial modules#8270

Merged
Evangelink merged 6 commits into
mainfrom
copilot/refactor-split-test-data-connection-sql
May 16, 2026
Merged

Refactor TestDataConnectionSql into focused partial modules#8270
Evangelink merged 6 commits into
mainfrom
copilot/refactor-split-test-data-connection-sql

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

TestDataConnectionSql.cs had grown into a 900+ line, multi-responsibility file spanning connection lifecycle, quoting, name parsing, schema discovery, and data reads. This change separates those concerns into focused partial-class files while preserving the existing API surface and NETFRAMEWORK-only behavior.

  • Core lifecycle

    • Kept construction, provider factory setup, connection state handling, metadata defaults, and Dispose in TestDataConnectionSql.cs.
    • Left the class entry point and factory method unchanged.
  • Quoting and identifier handling

    • Moved quote prefix/suffix resolution and provider-specific identifier quoting logic into TestDataConnectionSql.Quotes.cs.
    • Split name parsing / re-quoting mechanics into TestDataConnectionSql.Names.cs to isolate identifier normalization from provider quote discovery.
  • Schema inspection

    • Moved default-schema lookup, table/view enumeration, column lookup, and display-name formatting into TestDataConnectionSql.Schema.cs.
    • Kept the existing schema query flow and helper behavior intact.
  • Data access

    • Moved ReadTable and column projection SQL generation into TestDataConnectionSql.Data.cs.
  • Shared helpers and constants

    • Moved SQL-provider helpers, schema metadata types, and known OLE DB / ODBC provider constants into TestDataConnectionSql.Helpers.cs.

Example of the new structure:

internal partial class TestDataConnectionSql : TestDataConnection
{
    // TestDataConnectionSql.cs
}

internal partial class TestDataConnectionSql
{
    // TestDataConnectionSql.Quotes.cs
    // TestDataConnectionSql.Names.cs
    // TestDataConnectionSql.Schema.cs
    // TestDataConnectionSql.Data.cs
    // TestDataConnectionSql.Helpers.cs
}

Copilot AI requested review from Copilot and removed request for Copilot May 15, 2026 19:34
Copilot AI linked an issue May 15, 2026 that may be closed by this pull request
5 tasks
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 15, 2026 19:44
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 15, 2026 19:44
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 15, 2026 19:46
Copilot AI changed the title [WIP] Refactor TestDataConnectionSql into focused modules Refactor TestDataConnectionSql into focused partial modules May 15, 2026
Copilot AI requested a review from Evangelink May 15, 2026 19:46
@Evangelink Evangelink marked this pull request as ready for review May 16, 2026 08:33
Copilot AI review requested due to automatic review settings May 16, 2026 08:33
@Evangelink
Copy link
Copy Markdown
Member

@copilot fix the following build issues

@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Windows Debug)
src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Data.cs#L78

src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Data.cs(78,17): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'StringEx' does not exist in the current context
Check failure on line 23 in src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Helpers.cs

@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Windows Debug)
src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Helpers.cs#L23

src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Helpers.cs(23,61): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'StringEx' does not exist in the current context
Check failure on line 276 in src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Schema.cs

@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Windows Debug)
src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Schema.cs#L276

src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Schema.cs(276,19): error CS0246: (NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'DbCommand' could not be found (are you missing a using directive or an assembly reference?)
Check failure on line 7 in src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.cs

@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Windows Debug)
src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.cs#L7

src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.cs(7,1): error IDE0005: (NETCORE_ENGINEERING_TELEMETRY=Build) Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)
Check failure on line 5 in src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Data.cs

@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Windows Debug)
src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Data.cs#L5

src\Adapter\MSTestAdapter.PlatformServices\Data\TestDataConnectionSql.Data.cs(5,1): error IDE0005: (NETCORE_ENGINEERING_TELEMETRY=Build) Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 refactors TestDataConnectionSql into focused partial-class modules while preserving its NETFRAMEWORK-only data connection behavior.

Changes:

  • Keeps construction, factory setup, connection state, and disposal in the core file.
  • Moves identifier quoting/name parsing, schema discovery, helper types/constants, and table reads into separate partial files.
  • Converts TestDataConnectionSql to a partial class to support the split.
Show a summary per file
File Description
src/Adapter/MSTestAdapter.PlatformServices/Data/TestDataConnectionSql.cs Retains core lifecycle and changes the class to partial.
src/Adapter/MSTestAdapter.PlatformServices/Data/TestDataConnectionSql.Quotes.cs Adds quote prefix/suffix and identifier quoting helpers.
src/Adapter/MSTestAdapter.PlatformServices/Data/TestDataConnectionSql.Names.cs Adds table/name splitting and quote-joining logic.
src/Adapter/MSTestAdapter.PlatformServices/Data/TestDataConnectionSql.Schema.cs Adds schema, table/view, column, and default schema helpers.
src/Adapter/MSTestAdapter.PlatformServices/Data/TestDataConnectionSql.Data.cs Adds table reading and column projection SQL generation.
src/Adapter/MSTestAdapter.PlatformServices/Data/TestDataConnectionSql.Helpers.cs Adds shared provider helpers, metadata structs, and known provider constants.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 1

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 16, 2026

@copilot fix the following build issues

@azure-pipelines
...

Addressed in b6ead4e.

- TestDataConnectionSql.Data.cs: separate alias using from regular using with blank line (SA1516/IDE0055).
- TestDataConnectionSql.Helpers.cs: remove unused Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter using (IDE0005) and separate alias.
- TestDataConnectionSql.Names.cs / TestDataConnectionSql.Quotes.cs: remove unused MSTest.TestAdapter using (IDE0005).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 16, 2026 12:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new

@Evangelink Evangelink merged commit 037e9b0 into main May 16, 2026
14 of 21 checks passed
@Evangelink Evangelink deleted the copilot/refactor-split-test-data-connection-sql branch May 16, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Split TestDataConnectionSql.cs (905 lines) into focused modules

4 participants