Simplify SqlClient packaging with SDK pack and a generated .NET Standard contract
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- csharp, postgresql
- 领域
- backend, build-system
调研方向
Start by reading the SqlClient project and packaging files, the existing reference and unsupported-platform projects, and issue #4826; prototype source-based and assembly-based contract generation as the issue requests. Then compare the generated Standard contract with its existing baseline and concrete implementation APIs, and inspect package contents and dependency groups. Done means the acceptance criteria pass, including intermediate-library consumers and signed pack flows.
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem? Please describe.
SqlClient's packaging currently depends on separately maintained public API declarations, a reference assembly project, a generated unsupported-platform assembly project, and a hand-authored nuspec. This duplicates the implementation's API surface, adds build orchestration, and allows the contract and implementation to drift, as documented in #4826.
We want to simplify this to one packable SqlClient project and normal SDK-generated packaging while preserving all three package targets: net462, netstandard2.0, and net10.0.
The netstandard2.0 asset is a compile-time bridge for intermediate libraries. Those libraries ultimately run in an application targeting a concrete supported framework, which must resolve the real net462 or net10.0 implementation. Retaining this bridge does not imply a full .NET Standard runtime implementation.
Describe the solution you'd like
Intended package layout
lib/net462/Microsoft.Data.SqlClient.dll # Real implementation
lib/netstandard2.0/Microsoft.Data.SqlClient.dll # Generated contract/stub assembly
lib/net10.0/Microsoft.Data.SqlClient.dll # Real implementation
Include the appropriate XML documentation and localized satellite assemblies. Retain the package readme, icon, existing consumer family-version checks under build/ and buildTransitive/, and separate .snupkg symbols packaging. No managed assemblies should be shipped under ref/ or runtimes/.
Native SNI packages remain dependencies and retain their native runtime assets.
Proposed implementation plan
-
Prototype build-time Standard contract generation from the implementation.
- Do not maintain a second set of API declaration source files or a handwritten API allowlist.
- Prefer investigating source-based generation using the implementation's framework-dependent declarations; compare with assembly-based generation using GenAPI or an equivalent tool before committing to the approach.
- Generate source only under the intermediate output directory, not in source control.
- Produce Standard-compatible declarations with explicit
PlatformNotSupportedExceptionfallback behavior rather than a real Standard driver implementation. - Preserve public/protected signatures, generic constraints, constants, relevant attributes, and type forwards. Reuse existing type-forward sources where appropriate.
- Handle framework-specific API shapes explicitly. For example, the modern
SqlBatchderives fromDbBatch, which is not available in .NET Standard 2.0. Blindly generating declarations from the .NET 10 assembly is insufficient. - Audit conditional compilation: compiling source with neither
NETnorNETFRAMEWORKdefined does not by itself guarantee the intended Standard API surface. - Fail generation when declarations cannot be represented faithfully; do not silently omit APIs.
-
Make the implementation project the single packable SqlClient project.
- Target
net462;netstandard2.0;net10.0. - Compile existing implementation sources for the concrete targets and generated contract sources for Standard.
- Update the AKV provider's Project-mode reference from the reference project to the unified SqlClient project, preserving its Standard target and the intermediate-library scenario.
- Target
-
Replace the authored nuspec with normal SDK packaging.
- Move package metadata and explicit non-binary pack items into project properties/items.
- Remove custom nuspec token expansion, generated intermediate nuspec handling, and dependency suppression.
- Generate dependency groups from project/package references while preserving intended bounded sibling version ranges, compile exclusions, and transitive build-asset behavior in both Project and Package reference modes.
- Review differences between current project references and authored nuspec dependencies rather than accidentally changing the consumer graph.
- Remove the source nuspec. SDK pack will still generate the normal package manifest.
-
Remove obsolete projects and simplify orchestration.
- Remove separate ref/notsupported projects, duplicate declarations, solution entries, and build targets.
- Remove GenAPI tooling only if the selected generation approach and remaining repository uses no longer need it.
- Build the implementation once in ordinary build/pack flows.
- Preserve release build -> binary signing ->
pack --no-buildordering without rebuilding or modifying signed outputs.
-
Replace safeguards that currently depend on the reference project.
- Compare generated Standard contracts and concrete implementation public APIs against appropriate baselines, including signatures, attributes, and type forwards.
- Support historical baselines containing
ref/and future baselines containing onlylib/. - Update XML documentation validation and remove the separate reference-documentation pipeline step.
- Decide and document the IntelliSense XML policy: today
ref/has trimmed XML whilelib/has full documentation. Preserve full documentation for the API docs pipeline and explicitly account for any IntelliSense presentation change. - Update build orchestration tests, build documentation, and public API contribution guidance.
Acceptance criteria
- SqlClient exposes
net462,netstandard2.0, andnet10.0assets underlib/only, with no packagedref/assemblies or managed RID-specific assemblies. - The Standard contract is generated from the implementation during a clean build; no separately maintained API declarations are required.
- Generated Standard APIs are compared with the existing Standard contract during migration and checked for compatibility with the concrete implementations.
- A
netstandard2.0intermediate library consuming the package builds and runs through both anet462app and anet10.0app, with the appropriate real implementation selected. - The AKV provider builds and tests successfully in both Project and Package modes without retargeting solely because the reference project was removed.
- Standard stub fallback behavior is explicit, including a deliberate policy for static initialization/fields such as
SqlClientFactory.Instance(see #4081). - SDK-generated dependency groups/ranges and package contents are verified in both reference modes.
- Windows .NET Framework and Windows/Linux/macOS .NET 10 package consumers are validated, including RID-less builds, RID-specific publishing, native SNI resolution, and direct
lib/loading with required dependencies available. - Clean and incremental builds and signed
pack --no-buildflows work without stale generation or signed-binary replacement. - Documentation, localization, symbols, and API compatibility gates remain effective.
Describe alternatives you've considered
- Keep handwritten reference declarations: preserves duplicate maintenance and API-drift risk; does not meet the goal.
- Retain separate ref/notsupported projects: can preserve current behavior but does not simplify the build as intended.
- Generate from a concrete implementation assembly: potentially reuses existing GenAPI infrastructure, but requires framework-shape transformations and careful build ordering. Evaluate against source-based generation in the prototype.
- Implement the complete driver for .NET Standard 2.0: substantially larger compatibility/porting effort and unnecessary for the compile-time bridge requirement.
- Remove the Standard target or retarget all intermediate libraries: explicitly out of scope; Standard targeting must remain.
Additional context
Related open issues:
- #4239 - Replace platform-specific builds with runtime OS selection. This effort follows its managed
lib/<tfm>layout simplification while retaining the Standard bridge. - #4826 -
ref/assemblies do not match implementation assembly API surfaces. Generating the contract from implementation should remove the duplicate-maintenance root cause, with compatibility checks retained. - #4081 - Raise exception on calling
SqlClientFactory.Instancefrom facade assembly. Relevant to explicit, predictable behavior when the generated Standard stub is loaded instead of a concrete implementation.
This issue tracks the broader follow-up: generated Standard contracts, removal of separate ref/notsupported projects, and replacement of the authored nuspec with normal SDK packaging. The generation strategy requires a proof of concept before the detailed implementation is finalized.
- 主要语言
- C#
- 星标
- 1k
- 派生
- 352
- 平均合并
- 4 天 12 小时
- 30 天内合并 PR
- 86
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/SqlClient 的其他 Issue
-
Sync ExecuteReader on an STA thread deadlocks against a StateChange handler that marshals to the UI thread (OpenAsyncRetry path)可能重新可做 @mdaigle 于 43 天前认领,目前没有进行中的 PR。 未关闭External :link:
难度 2/5 1-3 小时 新手友好度 64/100
dotnet/SqlClient#4534 · 2 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
Area\Tests
难度 2/5 1-3 小时 新手友好度 68/100
dotnet/SqlClient#4377 · 2 条评论 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 62/100
dotnet/SqlClient#4957 · 2 条评论 ·
维护者通常 2 天内回复
-
难度 3/5 1-2 天 新手友好度 54/100
维护者通常 2 天内回复
-
Code Health :pill: Up-for-Grabs :raised_hands:
难度 5/5 一周以上 新手友好度 25/100
dotnet/SqlClient#4937 · 1 条评论 ·
维护者通常 2 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
bug elsa 3 prio low
难度 2/5 1-3 小时 新手友好度 75/100
elsa-workflows/elsa-core#9154 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
NethermindEth/nethermind#15452 ·
维护者通常 1 天内回复
-
kind:ux size:S
难度 2/5 1-3 小时 新手友好度 82/100
elsa-workflows/elsa-foundation#3563 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复