Skip to content

Conversation

@benrr101
Copy link
Contributor

@benrr101 benrr101 commented Jan 8, 2026

Description

This PR updates the Unit Test project to point at the common (merged) MDS project. There's some unconventional changes to make this work, though.

  • Unit Test project now references the common MDS csproj
  • Common MDS project updated to include strings/resx files
  • Common MDS project updated to have InternalsVisibleTo attribute
  • Unit Test project package references updated to match the common project format
  • Fixed SNI dll issues in Unit Test project by replacing copy targets with a package reference to the SNI package
    • This might not be the "right" solution (ie, it's so simple, idk why we wouldn't have tried it already)
    • I posit it's valid b/c MDS has a package reference to SNI, the version number is locked in via the central feed stuff
    • I took this approach b/c the copy targets had the build output hard-coded to include the OS in the path. The copy targets only applied to netfx, but I still needed to copy them in for netcore. For netcore, the OS will vary, and I really did not want to bring the same song and dance for OS variables into the test projects.
  • Temporarily introduce a new Test Common project that the Unit Test project references
    • This is the most controversial change, but I stress that it's temporary
    • The Test Common project maintains a reference to the MDS project, and all the test projects reference it.
    • We can't point Unit Test project at common MDS project without the Test Common project also pointin at common MDS project
    • We can't point the existing Test Common project at the common MDS project without breaking Functional/Manual tests
    • Thus, we either need to update all the test projects at once (big change, dangerous) or make a parallel version of the Test Common project.
    • I have chosen the latter option.
    • The plan for unwinding this is once the functional/manual test projects reference the common MDS project, they will also point to the parallel Test Common project. Once that happens, the existing test common can be deleted.

How does this impact our pipelines?

No changes were necessary to the CI/PR pipelines. The existing build.proj command for running the Unit Tests continues to work even after changing the MDS target. A small tweak was necessary to ensure that we weren't building unnecessary projects before running the tests, but that's no big issue, afaik. Pipelines should continue to Just Work™️

I considered making new targets in the build2.proj but decided to just get this out first. There's some cruft in the way we call the Unit Tests today, so leaving it as-is isn't making anything worse.

Issues

N/A

Testing

Locally the build.proj targets and running the unit tests inside the IDE still work.

Copilot AI review requested due to automatic review settings January 8, 2026 01:05
@benrr101 benrr101 requested a review from a team as a code owner January 8, 2026 01:05
@benrr101 benrr101 added Area\Tests Issues that are targeted to tests or test projects Common Project 🚮 Things that relate to the common project project labels Jan 8, 2026
Copy link
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 migrates the Unit Test project to reference the common (merged) Microsoft.Data.SqlClient project instead of the separate platform-specific projects (netfx/netcore). The changes introduce a temporary parallel Test Common project to avoid breaking existing Functional and Manual test projects during the migration.

Key Changes:

  • Updated Unit Test project to reference the unified MDS project and resolve SNI dependencies via package references
  • Added InternalsVisibleTo attribute and resource file configurations to the common MDS project
  • Created a temporary Microsoft.Data.SqlClient.TestCommon project that references the unified MDS project
  • Refactored test code to improve clarity and remove unnecessary try-catch blocks

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
build.proj Removed redundant project references from UnitTests ItemGroup since the dependencies are now managed by the test project itself
src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj Added InternalsVisibleTo for UnitTests assembly and configured embedded resource handling for Strings.resx files
src/Microsoft.Data.SqlClient/tests/Common/Microsoft.Data.SqlClient.TestCommon.csproj New temporary test common project that references the unified MDS project with necessary test dependencies
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj Restructured to reference the unified MDS project, use SNI package references instead of copy targets, and separate dependencies by target framework
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionFailoverTests.cs Improved test code clarity by extracting actions and removing unnecessary try-catch blocks
src/Microsoft.Data.SqlClient.sln Added the new Microsoft.Data.SqlClient.TestCommon project to the solution with build configurations

paulmedynski
paulmedynski previously approved these changes Jan 8, 2026
<NetStandardDriver Include="**/netcore/ref/Microsoft.Data.SqlClient*.csproj" />
<AKVProvider Include="**/add-ons/**/AzureKeyVaultProvider/*.csproj" />

<UnitTests Include="**/Common/Common.csproj" />
Copy link
Contributor

Choose a reason for hiding this comment

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

I had to include these so that the referenced projects are built and available for the proper target when we build the unit tests project. I'd be happy to get rid of them, but try building unit tests after cleaning the project to make sure everything still works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is something I'm working through right now in the failing build. I ignored the "--no-build" on the dotnet command and it tripped me up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Solution has been reached! The Run* target is now being used to build the project, so it shouldn't be necessary to include the dependency projects now.

Copilot AI review requested due to automatic review settings January 9, 2026 20:10
Copy link
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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings January 10, 2026 00:48
Copy link
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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

paulmedynski
paulmedynski previously approved these changes Jan 12, 2026
Copilot AI review requested due to automatic review settings January 12, 2026 18:39
@benrr101 benrr101 force-pushed the dev/russellben/common/unit-tests branch from af87573 to 6de0ab7 Compare January 12, 2026 18:39
Copy link
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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.73%. Comparing base (410afa7) to head (6de0ab7).

❗ There is a different number of reports uploaded between BASE (410afa7) and HEAD (6de0ab7). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (410afa7) HEAD (6de0ab7)
addons 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3870      +/-   ##
==========================================
- Coverage   76.68%   69.73%   -6.95%     
==========================================
  Files         269      263       -6     
  Lines       43246    66170   +22924     
==========================================
+ Hits        33163    46144   +12981     
- Misses      10083    20026    +9943     
Flag Coverage Δ
addons ?
netcore 69.69% <ø> (-7.01%) ⬇️
netfx 69.22% <ø> (-7.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cheenamalhotra cheenamalhotra added this to the 7.0.0-preview4 milestone Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area\Tests Issues that are targeted to tests or test projects Common Project 🚮 Things that relate to the common project project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants