Skip to content

Conversation

@paulmedynski
Copy link
Contributor

@paulmedynski paulmedynski commented Nov 10, 2025

Description

  • Updated key dependencies to the latest versions that don't trigger major version bumps.
  • Fixed all build warnings and Wave Analysis vulnerability warnings.
  • Updated .NET Framework project to be a moden SDK project.
  • Updated xUnit packages and made associated test changes for modernization.
  • Updated .NET Framework project to build on Linux.
    • Powershell targets still fail, but it's good enough for this branch which is close to EOL.
  • Updated official pipeline build version numbers to 5.1.8.

Testing

Existing CI should find any problems.

- Updated key dependencies to the latest versions that don't trigger major version bumps.
- Updated xUnit packages and made associated test changes for modernization.
- Updated .NET Framework project to build on Linux.
- Fixed build issues that only appear when building on Windows.
@paulmedynski paulmedynski added this to the 5.1.8 milestone Nov 10, 2025
Copilot AI review requested due to automatic review settings November 10, 2025 16:06
- Removed ancient obsolete copy of XunitExtensions project.
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 modernizes the build system and test infrastructure for Microsoft.Data.SqlClient by updating dependencies, migrating to SDK-style projects, and improving test code quality.

Key Changes

  • Dependency Updates: Azure.Identity (1.11.4 → 1.12.1), MSAL (4.61.3 → 4.78.0), Azure.Core (version ranges → 1.45.0), and test framework packages (xUnit 2.4.2 → 2.9.3, .NET Test SDK 17.4.1 → 17.12.0)
  • .NET Framework Project Modernization: Migrated netfx/src project to SDK-style format, removing legacy COM references and adding proper .NET Framework reference assemblies support
  • Test Code Improvements: Replaced Assert.False(true, message) anti-pattern with Assert.Fail(message), updated ActiveIssue attributes to use string parameters, and converted synchronous tests to properly async methods

Reviewed Changes

Copilot reviewed 93 out of 94 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tools/props/Versions.props Updated dependency versions across Azure SDK, MSAL, xUnit, and test infrastructure packages; changed Azure package versions from ranges to fixed versions
src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj Migrated to SDK-style project format, removed COM references to mscoree, added Microsoft.NETFramework.ReferenceAssemblies support
src/Microsoft.Data.SqlClient/tests/ManualTests/*.cs Modernized test assertions (Assert.Fail, proper async/await), updated ActiveIssue attributes to string format
src/Microsoft.Data.SqlClient/tests/FunctionalTests/*.cs Improved test assertions (Assert.Empty, Assert.Single), converted tests to async, added AssertExtensions and PlatformDetection helpers
src/Microsoft.Data.SqlClient/tests/**/Microsoft.Data.SqlClient.*.Tests.csproj Added xUnit and Microsoft.DotNet.XUnitExtensions package references, replaced project references with packages
src/Microsoft.Data.SqlClient/src/*/ActiveDirectoryAuthenticationProvider.cs Added pragma warnings to suppress CS0618 for obsolete MSAL API usage
src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj Removed explicit Microsoft.Win32.Registry reference, added Azure.Core package reference
src/Microsoft.Data.SqlClient.sln Removed Microsoft.DotNet.XUnitExtensions project reference and dependencies
build.proj Commented out Microsoft.DotNet.XUnitExtensions project from build targets
src/Directory.Build.props Added MSBuild workaround for synthetic project references and suppressed NETSDK1138 warning for .NET 6.0

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.35%. Comparing base (499b095) to head (7475943).

Files with missing lines Patch % Lines
...SqlClient/ActiveDirectoryAuthenticationProvider.cs 33.33% 2 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           release/5.1    #3754      +/-   ##
===============================================
- Coverage        72.29%   70.35%   -1.94%     
===============================================
  Files              293      293              
  Lines            61612    61928     +316     
===============================================
- Hits             44544    43572     -972     
- Misses           17068    18356    +1288     
Flag Coverage Δ
addons 92.38% <ø> (ø)
netcore 74.37% <33.33%> (-1.96%) ⬇️
netfx 68.75% <33.33%> (-1.18%) ⬇️

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.

- Fixed ManualTests SqlBulkCopy file inclusion issues.
@paulmedynski paulmedynski marked this pull request as draft November 10, 2025 17:48
- Fixed MDS nuspec to look for net462 artifacts in the correct place.
- Reverted SqlBulkCopy tests Helpers namespace change.
Copilot AI review requested due to automatic review settings November 10, 2025 18:20
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 96 out of 97 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/LocalDBTest/LocalDBTest.cs:147

  • Hardcoding the enum value (TargetFrameworkMonikers)0x4 instead of using the named enum member TargetFrameworkMonikers.Uap reduces code readability. The original code was clear about the intent. Since the TargetFrameworkMonikers enum is being removed from the local XUnit extensions and now comes from the NuGet package, verify that the value 0x4 corresponds to the correct enum member in the new package version.
    src/Microsoft.Data.SqlClient/tests/FunctionalTests/AssertExtensions.cs:317
  • The exception type changed from AssertActualExpectedException to EqualException, and the exception creation method changed from constructor to EqualException.ForMismatchedStrings(). The new method requires index parameters (0, 0) that may not accurately represent where the mismatch occurred in the byte arrays. Consider calculating the actual mismatch index to provide more accurate error messages.

- Fixed Helpers namespace for real.
- Added sunit.runner.json config to avoid XUnitExtensions strong name errors.
- Fixed SNI DLL copying for .NET Framework test projects.
Copilot AI review requested due to automatic review settings November 10, 2025 19:43
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 96 out of 97 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/tests/FunctionalTests/AssertExtensions.cs:317

  • The EqualException.ForMismatchedStrings call is missing the expected and actual array lengths which are required parameters. The correct signature should include the index position and lengths: EqualException.ForMismatchedStrings(expectedString, actualString, indexOfFirstDifference, indexOfFirstDifference) or similar. Please verify the correct overload for xUnit 2.9.3 and provide appropriate parameters.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor Author

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Commentary for reviewers.

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Buffers" Version="$(SystemBuffersVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true' and '$(IsUAPAssembly)' != 'true'">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're already including the NuGet package on line 31 for netstandard. Removing this fixed a duplication error for that target, and didn't seem to affect the others.

</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="$(AzureIdentityVersion)" />
<PackageReference Include="Azure.Core" Version="$(AzureCoreVersion)" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Necessary to avoid a transitive vulnerability.

</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="$(AzureCoreVersion)" />
<PackageReference Include="System.Private.Uri" Version="$(SystemPrivateUriVersion)" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Necessary to avoid a transitive vulnerability.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh boy - this was an old-style project. Converted it to modern SDK style.

<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From ancient times; unused here.

<Compile Include="SQL\RetryLogic\SqlConfigurationManagerReliabilityTest.cs" />
<Compile Include="SQL\SqlBulkCopyTest\AdjustPrecScaleForBulkCopy.cs" />
<Compile Include="SQL\SqlBulkCopyTest\AzureDistributedTransaction.cs" />
<Compile Include="SQL\SqlBulkCopyTest\ErrorOnRowsMarkedAsDeleted.cs" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorted all of these SqlBulkCopyTest files alphabetically.

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" Version="$(MicrosoftSqlServerSqlManagementObjectsVersion)" />
<PackageReference Include="System.Formats.Asn1" Version="$(SystemFormatsAsn1Version)" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Avoid transitive vulnerability.

"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"diagnosticMessages": true,
"parallelizeAssembly": true,
"shadowCopy": false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed this to avoid .NET Framework test failures refusing to load xUnit DLLs.

<dependency id="Azure.Core" version="1.45.0" />
<dependency id="Azure.Identity" version="1.12.1" />
<dependency id="Microsoft.Identity.Client" version="4.78.0" />
<dependency id="Microsoft.IdentityModel.JsonWebTokens" version="6.35.0" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't update these to 6.36.0 because then include major version bumps for transitive dependencies.

<file src="..\..\artifacts\Project\bin\Windows_NT\$Configuration$.AnyCPU\Microsoft.Data.SqlClient\netfx\zh-Hans\Microsoft.Data.SqlClient.resources.dll" target="lib\net462\zh-Hans\" exclude="" />
<file src="..\..\artifacts\Project\bin\Windows_NT\$Configuration$.AnyCPU\Microsoft.Data.SqlClient\netfx\zh-Hant\Microsoft.Data.SqlClient.resources.dll" target="lib\net462\zh-Hant\" exclude="" />

<file src="..\..\artifacts\Project\bin\Windows_NT\$Configuration$.AnyCPU\Microsoft.Data.SqlClient\netfx\net462\de\Microsoft.Data.SqlClient.resources.dll" target="lib\net462\de\" exclude="" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added net462\ to these paths since that's where the new .NET Framework SDK project puts them.

- Whoops - forget to add the new target file.
@paulmedynski paulmedynski marked this pull request as ready for review November 10, 2025 22:48
Copilot AI review requested due to automatic review settings November 10, 2025 22:48
Copilot finished reviewing on behalf of paulmedynski November 10, 2025 22:50
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 97 out of 98 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/tests/FunctionalTests/AssertExtensions.cs:317

  • The change from AssertActualExpectedException to EqualException is correct for xUnit 2.9.3, but the constructor call EqualException.ForMismatchedStrings(expectedString, actualString, 0, 0) may not work as intended. The last two parameters (0, 0) represent the index and pointer position in the strings. This should likely use actual mismatch positions or a different factory method. Consider using just new EqualException(expectedString, actualString) if the simpler constructor is available.

- Pipeline tweaks in preparation for the official 5.1.8 build.
Copy link
Contributor Author

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Commentary for reviewers.

# See the LICENSE file in the project root for more information. #
#################################################################################
parameters:
- name: mdsPackageVersion
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prefer template parameters to variables with no provenance.

stages:
- stage: buildAKV
displayName: 'Build AKV Provider'
- stage: buildMDS
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-arranged to build the MDS package before AKV, since the latter depends on the former and it makes sense to see it this way in the pipeline.

- Fixed variable -> parameter that I missed earlier.
- Added target framework to paths for .NET Framework DLL copying steps
Copilot AI review requested due to automatic review settings November 11, 2025 13:25
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 102 out of 103 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (2)

src/Microsoft.Data.SqlClient/tests/FunctionalTests/AssertExtensions.cs:313

  • The catch block catches EqualException and the throw statement calls EqualException.ForMismatchedStrings(). This change suggests migration to a newer xUnit version where AssertActualExpectedException was replaced with EqualException. However, the ForMismatchedStrings method signature with four parameters (two index parameters at the end) might not be correct. Verify that EqualException.ForMismatchedStrings accepts these parameters in xUnit 2.9.3, as this could cause runtime errors.
    src/Microsoft.Data.SqlClient/tests/FunctionalTests/AssertExtensions.cs:317
  • The catch block catches EqualException and the throw statement calls EqualException.ForMismatchedStrings(). This change suggests migration to a newer xUnit version where AssertActualExpectedException was replaced with EqualException. However, the ForMismatchedStrings method signature with four parameters (two index parameters at the end) might not be correct. Verify that EqualException.ForMismatchedStrings accepts these parameters in xUnit 2.9.3, as this could cause runtime errors.

- Ignoring ADO Library variables for NuGet and assembly versioning.
Copy link
Contributor Author

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Commentary for reviewers.

if ($tf.StartsWith('net4'))
{
Copy-Item "artifacts\${{parameters.referenceType }}\bin\Windows_NT\${{parameters.Configuration }}.AnyCPU\Microsoft.Data.SqlClient\netfx\Microsoft.Data.SqlClient.dll" "$software\win\$tf" -recurse
Copy-Item "artifacts\${{parameters.referenceType }}\bin\Windows_NT\${{parameters.Configuration }}.AnyCPU\Microsoft.Data.SqlClient\netfx\$tf\Microsoft.Data.SqlClient.dll" "$software\win\$tf" -recurse
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The updated .NET Framework project publishes artifacts into a new sub-directory using the target framework, similar to the .NET project. A side-effect of converting it to a modern SDK style prokject.

- group: AKV Release Variables
- name: AKVMajor

# The above Library contains variables named AKVMajor, AKVMinor, and AKVPatch.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've had enough of the problems trying to figure out where the version values come from. Now they come only from these YAML files.

Copy link
Contributor

@mdaigle mdaigle left a comment

Choose a reason for hiding this comment

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

Ideally would have liked to see this as three separate PRs: build improvements, xunit updates, and version bumps

<Compile Include="Microsoft\Data\SqlClient\TdsParserStateObjectFactory.Managed.cs" />
<Compile Include="Microsoft\Data\SqlClient\TdsParser.Unix.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true' and '$(IsUAPAssembly)' != 'true'">
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this here because it only applies to netstandard, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct - removing this had no effect on the other target frameworks. It is already included as a package ref for .NET Standard on line 961.


[Fact]
[SkipOnTargetFramework(~TargetFrameworkMonikers.Uap)]
[SkipOnTargetFramework(~(TargetFrameworkMonikers)0x4)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment here to capture that? for history :)

@paulmedynski
Copy link
Contributor Author

Ideally would have liked to see this as three separate PRs: build improvements, xunit updates, and version bumps.

Agreed - this one got away from me!

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.

3 participants