Skip to content

Remove platform-specific builds#4465

Merged
paulmedynski merged 8 commits into
dotnet:mainfrom
edwardneal:target-single-platforms/03-sni-and-remaining-types
Jul 23, 2026
Merged

Remove platform-specific builds#4465
paulmedynski merged 8 commits into
dotnet:mainfrom
edwardneal:target-single-platforms/03-sni-and-remaining-types

Conversation

@edwardneal

Copy link
Copy Markdown
Contributor

Description

This follows up #4207, feeding the same pattern through the SNI layer and removing the logic which sets _UNIX and _WINDOWS. By the end of this, we've got the SqlClient project building the same code for both Windows and non-Windows platforms, but without any changes to the structure of the NuGet package.

We can't move commit-by-commit and see a compiling project, but I've worked upwards from the SNI layer.

cc @benrr101

Issues

Follows up #4207.
Part of #4239.

Testing

Tests continue to pass, and I've checked the output of an application which has been trimmed. All but two types are removed as expected on Linux, OsConstants is folded to a constant and the managed SNI is retained.

With that being said, I'm running on Windows. I'd definitely appreciate a CI run to ensure that we've got a baseline of a working NuGet package on Linux in an untrimmed configuration.

@azure-pipelines

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

@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run

@paulmedynski paulmedynski moved this from To triage to In progress in SqlClient Board Jul 21, 2026
@paulmedynski paulmedynski moved this from In progress to In review in SqlClient Board Jul 21, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@paulmedynski

Copy link
Copy Markdown
Contributor

@edwardneal - Thanks for progressing this work! It will lead to a much more simplified repo, build system, pipelines, and NuGet package layout. I will review this eagerly :)

One ask though - can you benchmark before and after these changes? I'd like to see if there is any significant change we need to be aware of.

@paulmedynski paulmedynski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Love it! Just one comment/question.

@github-project-automation github-project-automation Bot moved this from In review to Waiting for customer in SqlClient Board Jul 21, 2026
@edwardneal

Copy link
Copy Markdown
Contributor Author

Initial benchmarks are below. All benchmarks are connecting to a locally-run SQL Server 2025 instance on Windows, with no AppContext switches set.

Header

BenchmarkDotNet v0.15.6, Windows 11 (10.0.26200.6584)
AMD Ryzen 7 6800U with Radeon Graphics 2.70GHz, 1 CPU, 16 logical and 8 physical cores
.NET SDK 10.0.302
  [Host]                             : .NET 10.0.10 (10.0.10, 10.0.1026.32716), X64 RyuJIT x86-64-v3
  main : .NET 10.0.10 (10.0.10, 10.0.1026.32716), X64 RyuJIT x86-64-v3
  PR       : .NET 10.0.10 (10.0.10, 10.0.1026.32716), X64 RyuJIT x86-64-v3
EnvironmentVariables=Empty  Runtime=.NET 10.0  

Summary

  • All of the code changes are in the hot path of connection opening/closing. These changes haven't had any performance impact.
  • There are no code changes in the data path, but I've benchmarked this for clarity's sake. Sending strings of various sizes (with various packet sizes, synchronously and asynchronously) is broadly unchanged. The variations in these benchmarks are mostly within the threshold of statistical noise, with a small number of cases where I started to contend with the server.
Connection open/close
Method Job Mean Error StdDev Ratio RatioSD Gen0 Completed Work Items Lock Contentions Allocated Alloc Ratio
Open main 5.239 μs 0.0520 μs 0.0486 μs 1.00 0.01 0.1678 - - 1.38 KB 1.00
Open PR 5.175 μs 0.0662 μs 0.0619 μs 0.99 0.01 0.1678 - - 1.38 KB 1.00
OpenAsync main 5.293 μs 0.0782 μs 0.0693 μs 1.00 0.02 0.1907 - - 1.56 KB 1.00
OpenAsync PR 5.305 μs 0.0775 μs 0.0725 μs 1.00 0.02 0.1907 - - 1.56 KB 1.00
Send strings
Method Job StringSizeMB PacketSize Mean Error StdDev Median Ratio RatioSD Completed Work Items Lock Contentions Allocated Alloc Ratio
SendLargeNVarchar main 1 -1 6.667 ms 0.1887 ms 0.5198 ms 6.575 ms 1.01 0.11 - - 6.45 KB 1.00
SendLargeNVarchar PR 1 -1 4.946 ms 0.1291 ms 0.3642 ms 4.905 ms 0.75 0.08 - - 6.45 KB 1.00
SendLargeNVarcharAsync main 1 -1 5.347 ms 0.1179 ms 0.3287 ms 5.310 ms 1.00 0.09 11.2266 - 14.92 KB 1.00
SendLargeNVarcharAsync PR 1 -1 5.295 ms 0.1296 ms 0.3504 ms 5.277 ms 0.99 0.09 11.5547 - 15.07 KB 1.01
SendLargeNVarchar main 1 512 30.615 ms 0.6117 ms 1.1931 ms 30.888 ms 1.00 0.05 - - 6.52 KB 1.00
SendLargeNVarchar PR 1 512 27.419 ms 0.2024 ms 0.1893 ms 27.430 ms 0.90 0.03 - - 6.42 KB 0.98
SendLargeNVarcharAsync main 1 512 28.215 ms 0.1856 ms 0.1736 ms 28.229 ms 1.00 0.01 3.0000 - 11.38 KB 1.00
SendLargeNVarcharAsync PR 1 512 28.320 ms 0.1261 ms 0.1179 ms 28.331 ms 1.00 0.01 3.0313 - 11.38 KB 1.00
SendLargeNVarchar main 1 8192 4.843 ms 0.1201 ms 0.3368 ms 4.797 ms 1.00 0.10 - - 6.45 KB 1.00
SendLargeNVarchar PR 1 8192 4.891 ms 0.1512 ms 0.3984 ms 4.803 ms 1.01 0.11 - - 6.45 KB 1.00
SendLargeNVarcharAsync main 1 8192 5.273 ms 0.1477 ms 0.4042 ms 5.172 ms 1.01 0.11 11.3359 - 14.97 KB 1.00
SendLargeNVarcharAsync PR 1 8192 5.332 ms 0.1175 ms 0.3255 ms 5.306 ms 1.02 0.10 11.0234 - 14.83 KB 0.99
SendLargeNVarchar main 1 32767 4.287 ms 0.1024 ms 0.2803 ms 4.260 ms 1.00 0.09 - - 6.45 KB 1.00
SendLargeNVarchar PR 1 32767 4.341 ms 0.0861 ms 0.2442 ms 4.348 ms 1.02 0.09 - - 6.45 KB 1.00
SendLargeNVarcharAsync main 1 32767 4.612 ms 0.1330 ms 0.3707 ms 4.502 ms 1.01 0.11 10.5313 - 14.59 KB 1.00
SendLargeNVarcharAsync PR 1 32767 4.990 ms 0.1780 ms 0.5135 ms 4.930 ms 1.09 0.14 10.7891 - 14.71 KB 1.01
SendLargeNVarchar main 5 -1 22.551 ms 1.3779 ms 4.0413 ms 22.163 ms 1.03 0.26 - - 6.44 KB 1.00
SendLargeNVarchar PR 5 -1 22.685 ms 0.9654 ms 2.8161 ms 21.852 ms 1.04 0.22 - - 6.42 KB 1.00
SendLargeNVarcharAsync main 5 -1 22.196 ms 0.7518 ms 2.1810 ms 21.876 ms 1.01 0.14 40.3438 - 28.54 KB 1.00
SendLargeNVarcharAsync PR 5 -1 23.751 ms 0.8915 ms 2.6147 ms 23.829 ms 1.08 0.16 40.9063 - 28.79 KB 1.01
SendLargeNVarchar main 5 512 207.071 ms 9.4475 ms 27.7080 ms 211.288 ms 1.02 0.19 - - 6.49 KB 1.00
SendLargeNVarchar PR 5 512 209.346 ms 9.2800 ms 27.2166 ms 205.536 ms 1.03 0.19 - - 6.49 KB 1.00
SendLargeNVarcharAsync main 5 512 208.739 ms 9.2665 ms 27.1770 ms 212.585 ms 1.02 0.19 3.0000 - 11.45 KB 1.00
SendLargeNVarcharAsync PR 5 512 214.738 ms 8.7773 ms 25.7422 ms 218.809 ms 1.05 0.19 3.0000 - 11.45 KB 1.00
SendLargeNVarchar main 5 8192 30.837 ms 1.1503 ms 3.3554 ms 30.533 ms 1.01 0.16 - - 6.43 KB 1.00
SendLargeNVarchar PR 5 8192 30.039 ms 0.9520 ms 2.7770 ms 30.036 ms 0.99 0.14 - - 6.43 KB 1.00
SendLargeNVarcharAsync main 5 8192 25.447 ms 0.9726 ms 2.8524 ms 25.182 ms 1.01 0.16 40.1250 - 28.43 KB 1.00
SendLargeNVarcharAsync PR 5 8192 25.343 ms 0.7350 ms 2.1323 ms 25.227 ms 1.01 0.14 39.1250 - 27.96 KB 0.98
SendLargeNVarchar main 5 32767 18.497 ms 0.4735 ms 1.3432 ms 18.396 ms 1.01 0.10 - - 6.42 KB 1.00
SendLargeNVarchar PR 5 32767 18.947 ms 0.6081 ms 1.7250 ms 18.850 ms 1.03 0.12 - - 6.42 KB 1.00
SendLargeNVarcharAsync main 5 32767 25.098 ms 0.6805 ms 1.9526 ms 24.850 ms 1.01 0.11 42.5625 - 29.57 KB 1.00
SendLargeNVarcharAsync PR 5 32767 26.601 ms 0.7613 ms 2.2208 ms 26.558 ms 1.07 0.12 43.6875 - 30.1 KB 1.02
SendLargeNVarchar main 10 -1 50.269 ms 2.8828 ms 8.3634 ms 50.497 ms 1.03 0.24 - - 6.44 KB 1.00
SendLargeNVarchar PR 10 -1 43.540 ms 1.8441 ms 5.4085 ms 43.497 ms 0.89 0.18 - - 6.43 KB 1.00
SendLargeNVarcharAsync main 10 -1 47.085 ms 1.6281 ms 4.6714 ms 46.902 ms 1.01 0.14 78.7000 - 46.54 KB 1.00
SendLargeNVarcharAsync PR 10 -1 48.458 ms 1.9052 ms 5.5877 ms 48.361 ms 1.04 0.16 69.2500 - 42.1 KB 0.90
SendLargeNVarchar main 10 512 273.866 ms 1.6934 ms 1.5840 ms 273.828 ms 1.00 0.01 - - 6.59 KB 1.00
SendLargeNVarchar PR 10 512 274.718 ms 1.8263 ms 1.5250 ms 275.035 ms 1.00 0.01 - - 6.59 KB 1.00
SendLargeNVarcharAsync main 10 512 274.635 ms 2.8040 ms 2.6229 ms 275.059 ms 1.00 0.01 3.0000 - 11.56 KB 1.00
SendLargeNVarcharAsync PR 10 512 275.148 ms 1.6705 ms 1.4808 ms 275.121 ms 1.00 0.01 3.0000 - 11.56 KB 1.00
SendLargeNVarchar main 10 8192 41.030 ms 1.6864 ms 4.8926 ms 40.748 ms 1.01 0.17 - - 6.43 KB 1.00
SendLargeNVarchar PR 10 8192 42.091 ms 1.9770 ms 5.7983 ms 42.011 ms 1.04 0.19 - - 6.44 KB 1.00
SendLargeNVarcharAsync main 10 8192 46.344 ms 1.5367 ms 4.5070 ms 46.101 ms 1.01 0.14 79.5833 - 46.95 KB 1.00
SendLargeNVarcharAsync PR 10 8192 45.242 ms 1.9632 ms 5.7267 ms 45.298 ms 0.99 0.16 80.5000 - 47.38 KB 1.01
SendLargeNVarchar main 10 32767 48.640 ms 1.9232 ms 5.6099 ms 48.292 ms 1.01 0.17 - - 6.44 KB 1.00
SendLargeNVarchar PR 10 32767 47.495 ms 1.8447 ms 5.4393 ms 46.688 ms 0.99 0.16 - - 6.44 KB 1.00
SendLargeNVarcharAsync main 10 32767 38.588 ms 1.1072 ms 3.1766 ms 38.282 ms 1.01 0.12 83.9167 - 48.83 KB 1.00
SendLargeNVarcharAsync PR 10 32767 37.515 ms 1.1693 ms 3.3360 ms 37.535 ms 0.98 0.12 84.9167 - 49.32 KB 1.01
SendLargeNVarchar main 25 -1 118.600 ms 3.8208 ms 10.9009 ms 118.755 ms 1.01 0.13 - - 6.46 KB 1.00
SendLargeNVarchar PR 25 -1 115.573 ms 3.3373 ms 9.4128 ms 113.654 ms 0.98 0.12 - - 6.46 KB 1.00
SendLargeNVarcharAsync main 25 -1 96.830 ms 2.6411 ms 7.5353 ms 96.496 ms 1.01 0.11 190.8000 - 99.04 KB 1.00
SendLargeNVarcharAsync PR 25 -1 93.688 ms 2.4113 ms 6.8404 ms 93.340 ms 0.97 0.10 184.2000 - 96 KB 0.97
SendLargeNVarchar main 25 512 1,014.586 ms 66.0440 ms 193.6957 ms 1,012.658 ms 1.04 0.28 - - 6.63 KB 1.00
SendLargeNVarchar PR 25 512 689.357 ms 6.3879 ms 5.9752 ms 687.842 ms 0.70 0.14 - - 6.7 KB 1.01
SendLargeNVarcharAsync main 25 512 689.417 ms 8.3850 ms 7.8433 ms 691.899 ms 1.00 0.02 3.0000 - 11.64 KB 1.00
SendLargeNVarcharAsync PR 25 512 688.826 ms 8.2662 ms 7.3278 ms 685.593 ms 1.00 0.02 3.0000 - 11.64 KB 1.00
SendLargeNVarchar main 25 8192 92.872 ms 2.6323 ms 7.5948 ms 91.752 ms 1.01 0.11 - - 6.45 KB 1.00
SendLargeNVarchar PR 25 8192 92.237 ms 2.6555 ms 7.8297 ms 92.144 ms 1.00 0.12 - - 6.45 KB 1.00
SendLargeNVarcharAsync main 25 8192 98.775 ms 2.9316 ms 8.5050 ms 98.938 ms 1.01 0.12 201.0000 - 103.86 KB 1.00
SendLargeNVarcharAsync PR 25 8192 99.568 ms 3.2071 ms 9.4058 ms 99.433 ms 1.02 0.13 201.8000 - 104.25 KB 1.00
SendLargeNVarchar main 25 32767 82.018 ms 2.9511 ms 8.5147 ms 81.550 ms 1.01 0.14 - - 6.45 KB 1.00
SendLargeNVarchar PR 25 32767 105.784 ms 4.6065 ms 13.2908 ms 103.557 ms 1.30 0.21 - - 6.46 KB 1.00
SendLargeNVarcharAsync main 25 32767 87.676 ms 2.8347 ms 8.0877 ms 85.889 ms 1.01 0.13 204.3333 - 105.38 KB 1.00
SendLargeNVarcharAsync PR 25 32767 88.561 ms 3.4046 ms 9.9850 ms 85.873 ms 1.02 0.14 204.6000 - 105.46 KB 1.00
SendLargeNVarchar main 50 -1 193.738 ms 9.9349 ms 29.2934 ms 183.473 ms 1.02 0.21 - - 6.49 KB 1.00
SendLargeNVarchar PR 50 -1 167.594 ms 3.5545 ms 10.2555 ms 166.211 ms 0.88 0.14 - - 6.49 KB 1.00
SendLargeNVarcharAsync main 50 -1 174.434 ms 4.4999 ms 12.7654 ms 173.382 ms 1.01 0.10 404.3333 - 199.21 KB 1.00
SendLargeNVarcharAsync PR 50 -1 181.795 ms 5.6690 ms 16.4467 ms 179.546 ms 1.05 0.12 390.0000 - 192.34 KB 0.97
SendLargeNVarchar main 50 512 1,378.289 ms 19.7895 ms 18.5111 ms 1,368.379 ms 1.00 0.02 - - 6.7 KB 1.00
SendLargeNVarchar PR 50 512 1,382.526 ms 17.0640 ms 15.9617 ms 1,377.199 ms 1.00 0.02 - - 6.7 KB 1.00
SendLargeNVarcharAsync main 50 512 1,373.170 ms 26.9504 ms 29.9553 ms 1,356.539 ms 1.00 0.03 3.0000 - 11.64 KB 1.00
SendLargeNVarcharAsync PR 50 512 1,377.261 ms 20.0606 ms 18.7647 ms 1,382.319 ms 1.00 0.02 3.0000 - 11.64 KB 1.00
SendLargeNVarchar main 50 8192 166.561 ms 3.3073 ms 9.3824 ms 165.226 ms 1.00 0.08 - - 6.49 KB 1.00
SendLargeNVarchar PR 50 8192 172.481 ms 4.0081 ms 11.7550 ms 169.743 ms 1.04 0.09 - - 6.47 KB 1.00
SendLargeNVarcharAsync main 50 8192 177.168 ms 4.2792 ms 12.5502 ms 176.290 ms 1.00 0.10 378.6667 - 187.18 KB 1.00
SendLargeNVarcharAsync PR 50 8192 175.191 ms 4.9979 ms 14.6580 ms 172.157 ms 0.99 0.11 402.6667 - 198.43 KB 1.06
SendLargeNVarchar main 50 32767 150.089 ms 3.1175 ms 9.0939 ms 147.571 ms 1.00 0.08 - - 6.49 KB 1.00
SendLargeNVarchar PR 50 32767 196.865 ms 6.8835 ms 19.9704 ms 196.642 ms 1.32 0.15 - - 6.49 KB 1.00
SendLargeNVarcharAsync main 50 32767 162.842 ms 3.9702 ms 11.4550 ms 160.250 ms 1.00 0.10 404.7500 - 199.39 KB 1.00
SendLargeNVarcharAsync PR 50 32767 156.194 ms 3.1207 ms 8.6474 ms 154.322 ms 0.96 0.08 406.0000 - 199.91 KB 1.00

@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@paulmedynski paulmedynski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Amazing!

@paulmedynski paulmedynski moved this from Waiting for customer to In review in SqlClient Board Jul 22, 2026
@paulmedynski
paulmedynski enabled auto-merge (squash) July 22, 2026 19:14
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.45%. Comparing base (fdebcd2) to head (99703db).
⚠️ Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
...src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.cs 42.85% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4465      +/-   ##
==========================================
- Coverage   65.83%   62.45%   -3.39%     
==========================================
  Files         287      283       -4     
  Lines       43763    66821   +23058     
==========================================
+ Hits        28812    41730   +12918     
- Misses      14951    25091   +10140     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 62.45% <42.85%> (?)

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

☔ View full report in Codecov by Harness.
📢 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.

@benrr101 benrr101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fantastic work, thank you so much @edwardneal !! I'm surprised it was so easy!

There's still work to do to rework the nuget package and such, but that's something I'd be happy to take on. And that next step to eliminate the ref and unsupported projects is something I've wanted to do since I joined the team a while ago 😅

@paulmedynski
paulmedynski merged commit d040700 into dotnet:main Jul 23, 2026
358 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in SqlClient Board Jul 23, 2026
@edwardneal
edwardneal deleted the target-single-platforms/03-sni-and-remaining-types branch July 23, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants