Skip to content

Document multiple client proxy patterns#1470

Merged
AArnott merged 2 commits into
mainfrom
aarnott-jsonrpc-connection-docs
Jun 23, 2026
Merged

Document multiple client proxy patterns#1470
AArnott merged 2 commits into
mainfrom
aarnott-jsonrpc-connection-docs

Conversation

@AArnott

@AArnott AArnott commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

Users often attempt to call static JsonRpc.Attach<T> multiple times on the same stream to create multiple client proxies. This is a common mistake that leads to failures because each static call creates a distinct JsonRpc instance, and multiple instances cannot safely share one transport.

Changes

This PR documents the three supported patterns for constructing multiple client proxies over a single JSON-RPC connection, with working code examples:

  1. Create one proxy implementing multiple interfaces at once

    • Single proxy object implementing multiple RPC interface contracts
    • Simplest option when the set of interfaces is known upfront
  2. Create JsonRpc first, then call instance Attach<T> multiple times

    • Most flexible pattern for creating proxies incrementally
    • Clear separation between transport setup and proxy creation
  3. Extract JsonRpc from the first proxy using IJsonRpcClientProxy

    • Useful when starting with a static proxy attachment
    • Shows the relationship between proxies and the underlying connection

Files Changed

  • docfx/docs/proxies.md: Added new "Multiple proxies on one connection" section with clear guidance and code references for each pattern
  • samples/Proxies.cs: Added working code examples for all three patterns with dedicated #region markers for documentation

All samples compile and pass tests.

Add comprehensive documentation and working examples for the three patterns
to construct multiple client proxies over a single JSON-RPC connection:

1. Create one proxy implementing multiple interfaces at once
2. Create JsonRpc first, then call instance Attach<T> multiple times
3. Create the first proxy with static Attach<T>, extract the JsonRpc instance
   through IJsonRpcClientProxy, then call instance Attach<T>

This addresses the common mistake of calling static Attach<T> multiple times
on the same stream (which creates multiple distinct JsonRpc instances that
cannot safely share one transport).

Includes code samples in samples/Proxies.cs with dedicated regions for each
pattern and reference documentation in docfx/docs/proxies.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 23, 2026 14:25
@AArnott AArnott enabled auto-merge June 23, 2026 14:26

Copilot AI left a comment

Copy link
Copy Markdown

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 adds documentation and sample code showing the supported ways to create multiple strongly-typed client proxies over a single StreamJsonRpc connection, avoiding the common mistake of calling static JsonRpc.Attach<T> multiple times on the same stream.

Changes:

  • Added a new “Multiple proxies on one connection” section to the proxies documentation with guidance and snippet references.
  • Added sample code regions demonstrating three supported multi-proxy patterns (multi-interface proxy, multiple instance Attach<T> calls, and extracting JsonRpc from an existing proxy).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
docfx/docs/proxies.md Documents the supported multi-proxy patterns and links to corresponding sample snippets.
samples/Proxies.cs Provides the code examples (with #region markers) used by the documentation.

Comment thread samples/Proxies.cs
Rename multi-proxy sample regions to MultipleProxiesPattern1/2/3 and
update doc snippet anchors so the documented pattern order matches the
sample region naming.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AArnott AArnott merged commit dd89676 into main Jun 23, 2026
9 checks passed
@AArnott AArnott deleted the aarnott-jsonrpc-connection-docs branch June 23, 2026 16:52
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