microsoft / microsoft/vs-streamjsonrpc
Strongly-typed requests with named arguments produce empty params object with SystemTextJsonFormatter
Open
Nobody has claimed this yet.
bug
- Dominant language
- C#
- Stars
- 937
- Forks
- 178
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 28
Description
net9.0, StreamJsonRpc 2.22.11
Interface declaration
public interface TestInterface
{
public Task<int> add(int a, int b);
}
Strongly-typed request with named arguments with JsonMessageFormatter
Pipe pipe = new();
var formatter = new JsonMessageFormatter();
var handler = new LengthHeaderMessageHandler(pipe.Writer, pipe.Reader, formatter);
var jsonRpc = new JsonRpc(handler);
jsonRpc.TraceSource.Listeners.Add(new ConsoleTraceListener());
jsonRpc.TraceSource.Switch.Level = SourceLevels.Verbose;
jsonRpc.StartListening();
JsonRpcProxyOptions JsonRpcProxyOptions = new()
{
ServerRequiresNamedArguments = true
};
TestInterface testInterface = jsonRpc.Attach<TestInterface>(JsonRpcProxyOptions);
await testInterface.add(123, 456);
Partial console output
JsonRpc Verbose: 8 : Sent: {
"jsonrpc": "2.0",
"id": 2,
"method": "add",
"params": {
"a": 123,
"b": 456
}
}
Strongly-typed request with named arguments with SystemTextJsonFormatter
Pipe pipe = new();
var formatter = new SystemTextJsonFormatter();
var handler = new LengthHeaderMessageHandler(pipe.Writer, pipe.Reader, formatter);
var jsonRpc = new JsonRpc(handler);
jsonRpc.TraceSource.Listeners.Add(new ConsoleTraceListener());
jsonRpc.TraceSource.Switch.Level = SourceLevels.Verbose;
jsonRpc.StartListening();
JsonRpcProxyOptions JsonRpcProxyOptions = new()
{
ServerRequiresNamedArguments = true
};
TestInterface testInterface = jsonRpc.Attach<TestInterface>(JsonRpcProxyOptions);
await testInterface.add(123, 456);
Partial console output
JsonRpc Verbose: 8 : Sent: {"jsonrpc":"2.0","id":2,"method":"add","params":{}}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the strongly-typed named-argument request with SystemTextJsonFormatter and compare its output with JsonMessageFormatter. Inspect the JsonRpc.Attach proxy path, JsonRpcProxyOptions, and the two formatter entry points to find why parameter names are omitted. Done means the System.Text.Json request contains "a": 123 and "b": 456, with coverage for this repro.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100