Skip to content

Add netstandard and net10 targets to C# SDK#1320

Merged
stephentoub merged 8 commits into
mainfrom
stephentoub/netstandard-target
May 17, 2026
Merged

Add netstandard and net10 targets to C# SDK#1320
stephentoub merged 8 commits into
mainfrom
stephentoub/netstandard-target

Conversation

@stephentoub
Copy link
Copy Markdown
Collaborator

Adds downlevel and current-target coverage for the C# SDK so netstandard2.0 consumers can use the package while newer TFMs keep their modern framework-provided behavior.

Summary

  • Multi-targets the SDK for net8.0, net10.0, and netstandard2.0.
  • Adds downlevel-only polyfills under dotnet/src/Polyfills, with extension members placed in the BCL namespaces they polyfill.
  • Keeps System.Text.Json as a package dependency only for TFMs that are not compatible with the net10.0 surface area.
  • Uses a downlevel Regex fallback instead of a fake GeneratedRegexAttribute, and adds MCP-style IsExternalInit type forwarding.
  • Updates JSON-RPC ValueTask<T> unwrapping to use declared return-type metadata, avoiding trim/AOT suppressions.
  • Adds Windows-only net472 test coverage so the netstandard2.0 asset is exercised.

Validation

  • dotnet build dotnet\src\GitHub.Copilot.SDK.csproj --no-restore --nologo --verbosity:minimal /tl:off
  • dotnet test dotnet\test\GitHub.Copilot.SDK.Test.csproj --no-restore --nologo --verbosity:minimal /tl:off --filter "FullyQualifiedName!~E2E"

Multi-target the C# SDK for net8.0, net10.0, and netstandard2.0, with downlevel-only polyfills for APIs missing from netstandard2.0.

Add Windows-only net472 test coverage so the netstandard2.0 asset is exercised, and keep net10.0 on the shared System.Text.Json surface.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 17, 2026 20:04
@stephentoub stephentoub requested a review from a team as a code owner May 17, 2026 20:04
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
@github-actions

This comment has been minimized.

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

Adds multi-targeting and downlevel support for the .NET SDK so it can ship net8.0, net10.0, and netstandard2.0 assets while preserving newer framework behavior where available.

Changes:

  • Multi-targets the SDK and tests, adding Windows-only net472 test coverage for the netstandard2.0 asset.
  • Adds internal downlevel polyfills for missing BCL APIs/attributes.
  • Updates JSON-RPC ValueTask<T> unwrapping and downlevel regex/uninitialized-object handling.
Show a summary per file
File Description
dotnet/Directory.Build.props Removes the shared default target framework.
dotnet/Directory.Packages.props Adds package versions needed by downlevel targets.
dotnet/src/Client.cs Adds downlevel regex fallback and RID import cleanup.
dotnet/src/GitHub.Copilot.SDK.csproj Adds SDK multi-targeting and netstandard-specific dependencies/polyfills.
dotnet/src/JsonRpc.cs Updates ValueTask<T> result extraction using declared return-type metadata.
dotnet/src/Types.cs Adjusts nullability after string-token validation.
dotnet/src/Polyfills/ArrayBufferWriter.cs Adds downlevel ArrayBufferWriter<T>.
dotnet/src/Polyfills/BclAttributes.cs Adds compiler/BCL attribute polyfills.
dotnet/src/Polyfills/CodeAnalysisAttributes.cs Adds code-analysis attribute polyfills.
dotnet/src/Polyfills/DataAnnotationsAttributes.cs Adds Base64StringAttribute polyfill.
dotnet/src/Polyfills/DownlevelExtensions.cs Adds extension-based polyfills for missing framework APIs.
dotnet/src/Polyfills/IsExternalInit.cs Adds downlevel IsExternalInit and forwarding for newer TFMs.
dotnet/src/Polyfills/TaskCompletionSource.cs Adds non-generic TaskCompletionSource polyfill.
dotnet/src/Polyfills/Utf8.cs Adds downlevel Utf8.TryWrite polyfill.
dotnet/test/GitHub.Copilot.SDK.Test.csproj Adds Windows-only net472 test target and conditional test settings.
dotnet/test/Unit/JsonRpcTests.cs Adjusts in-memory stream test helper for downlevel stream APIs.
dotnet/test/Unit/SerializationTests.cs Uses downlevel uninitialized-object API when needed.

Copilot's findings

  • Files reviewed: 17/17 changed files
  • Comments generated: 5

Comment thread dotnet/Directory.Build.props
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Outdated
Comment thread dotnet/src/GitHub.Copilot.SDK.csproj
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs
Comment thread dotnet/src/Polyfills/Utf8.cs
Narrow socket connect exception handling and use a using declaration for cancellation registration disposal in the downlevel polyfills.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Add an explicit target framework for the sample project now that the shared default was removed, guard target-framework compatibility checks during outer builds, and fix formatting in the downlevel polyfill.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Multi-targeted projects run an outer build with no TargetFramework. Skip the CLI download/copy targets there so clean CI builds do not require CopilotCliVersion before the generated props file is available.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Fix downlevel Unix epoch and UTF-8 writing behavior, add best-effort non-Windows process tree cleanup, and avoid parallel version props generation across target frameworks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Ensure the generated Copilot CLI version property is populated before the CLI download target for every target framework, and fix remaining polyfill formatting caught by dotnet format.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Comment thread dotnet/src/Polyfills/DownlevelExtensions.cs Fixed
Ensure the Copilot CLI version is read before local SDK build targets need it, while keeping generated props creation limited to pack. Also simplifies the downlevel pgrep error handling to avoid the Linux formatting issue.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Make the descendant process parsing filter explicit and replace empty best-effort cleanup catches with debug diagnostics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR modifies only the .NET SDK (dotnet/) to add multi-targeting support (net8.0, net10.0, netstandard2.0) along with downlevel polyfills — it introduces no new public API surface.

No cross-SDK consistency concerns. Changes are limited to:

  • Build configuration (Directory.Build.props, .csproj files)
  • Internal polyfills (dotnet/src/Polyfills/) for downlevel TFM compatibility
  • JSON-RPC plumbing (JsonRpc.cs) using declared return-type metadata to avoid trim/AOT suppressions

No equivalent changes are needed in the Node.js, Python, or Go SDKs — this is .NET-ecosystem-specific infrastructure.

Generated by SDK Consistency Review Agent for issue #1320 · ● 131.4K ·

@stephentoub stephentoub merged commit f445b5c into main May 17, 2026
28 checks passed
@stephentoub stephentoub deleted the stephentoub/netstandard-target branch May 17, 2026 21:35
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