Skip to content

Enhance CLI build process and strong-name sign .NET SDK#3

Merged
anishi1222 merged 4 commits into
anishi1222:mainfrom
github:main
Jun 24, 2026
Merged

Enhance CLI build process and strong-name sign .NET SDK#3
anishi1222 merged 4 commits into
anishi1222:mainfrom
github:main

Conversation

@anishi1222

Copy link
Copy Markdown
Owner

This pull request introduces support for intercepting and handling Copilot LLM inference requests at the client level, allowing custom request handlers to be injected and tested. It also adds several polyfills and downlevel extensions to improve compatibility with .NET Standard 2.0, and includes new end-to-end tests for error and cancellation scenarios in custom LLM inference handlers.

Client LLM Inference Interception and Handler Injection:

  • Added a new RequestHandler property to CopilotClientOptions, allowing clients to provide a custom CopilotRequestHandler for intercepting all LLM inference requests. The client registers this handler globally if set, routing all model-layer HTTP/WebSocket requests through it instead of the runtime's default outbound calls. (dotnet/src/Types.cs, dotnet/src/Client.cs) [1] [2] [3] [4] [5]

  • Implemented the logic in CopilotClient to build and register these client-global API handlers on connection, and to configure the runtime to use the client-provided LLM inference provider when appropriate. (dotnet/src/Client.cs) [1] [2] [3] [4] [5]

Testing and Error Handling Improvements:

  • Added comprehensive end-to-end tests (CopilotRequestCancelErrorE2ETests) to verify that the client correctly handles thrown errors and cancellation in custom LLM inference request handlers, ensuring that errors are surfaced and cancellations are observed as expected. (dotnet/test/E2E/CopilotRequestCancelErrorE2ETests.cs)

Polyfills and Downlevel Extensions for .NET Standard 2.0:

  • Introduced polyfills for missing APIs in .NET Standard 2.0, including:
    • Extensions for Stream and Encoding to handle span/memory-based read/write and string conversions.
    • Extensions for HttpContent to provide cancellation support.
    • Polyfill for ValueWebSocketReceiveResult and related extensions for WebSocket to support memory-based send/receive operations. (dotnet/src/Polyfills/DownlevelExtensions.cs) [1] [2]

Build and Signing Enhancements:

  • Configured strong name signing for the GitHub.Copilot.SDK assembly by specifying an Open.snk key file and enabling assembly signing in the build properties. (dotnet/Directory.Build.props)

Process Shutdown and Cleanup Logic:

  • Simplified and clarified the process cleanup logic by removing unnecessary waiting for the runtime to self-exit (which it never does), ensuring the child process is terminated and reaped immediately after shutdown. (dotnet/src/Client.cs) [1] [2]

These changes enable advanced customization and testing scenarios for Copilot LLM inference, improve cross-platform compatibility, and streamline process management.

SteveSandersonMS and others added 4 commits June 23, 2026 10:58
…ation (#1776)

* fix(rust): backdate extracted CLI mtime to stop self-invalidation

When `bundled-cli` is off, `build.rs` watches the extracted CLI binary via
`cargo:rerun-if-changed` so a deleted cache binary forces a re-extract. On a
cold cache the same build script *creates* that binary mid-build, after the
download — so its mtime ends up newer than cargo's build-script `output`
reference (stamped when the script was spawned). The next identical `cargo`
invocation then sees the watched file as "changed", reruns build.rs, recompiles
the SDK crate, and relinks every downstream crate (observed ~9 min of wasted CI
on a second cargo invocation in the same job).

Backdate the staged binary's mtime to the Unix epoch before the atomic rename
(rename preserves mtime), so it lands unambiguously older than any real build
reference and a no-change rebuild stays a true no-op. Best-effort: on error we
emit a `cargo:warning` and continue, reverting to the prior redundant-rebuild
behaviour rather than breaking the build. The deleted-file recovery contract is
untouched — a missing file still can't be stat'd, so cargo still reruns.

Embed mode (`bundled-cli` on) is unaffected: it emits no `rerun-if-changed` on
any build-created file.

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

* refactor(rust): write staging binary through a single file handle

Address review: open the staging file once and perform the write, permission-set, and mtime-backdate on one handle instead of reopening it for each step. Write and chmod failures stay fatal; the epoch backdate stays best-effort (warn and continue). Behavior is otherwise unchanged: the extracted binary still lands epoch-dated so a no-change rebuild is a true no-op.

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the canonical .NET Open.snk key to strong-name sign the GitHub.Copilot.SDK assembly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@anishi1222 anishi1222 merged commit 4ee0cc5 into anishi1222:main Jun 24, 2026
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.

4 participants