-
Notifications
You must be signed in to change notification settings - Fork 161
Address a few small nits noticed while browsing #1158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using System.Buffers; | ||
| using System.Buffers.Binary; | ||
| using System.IO.Pipelines; | ||
| using Nerdbank.Streams; | ||
| using StreamJsonRpc.Protocol; | ||
|
|
@@ -109,7 +110,7 @@ protected override void Write(JsonRpcMessage content, CancellationToken cancella | |
| } | ||
|
|
||
| // Now go back and fill in the header with the actual content length. | ||
| Utilities.Write(this.Writer.GetSpan(sizeof(int)), checked((int)contentSequence.Length)); | ||
| BinaryPrimitives.WriteInt32BigEndian(this.Writer.GetSpan(sizeof(int)), checked((int)contentSequence.Length)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this another one that's going to cause you to load a library you didn't want to? Hmm, probably not, since you're already using span. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for checking. Ya, we're using System.Memory heavily throughout the library. |
||
| this.Writer.Advance(sizeof(int)); | ||
| contentSequence.CopyTo(this.Writer); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -294,8 +294,8 @@ internal static TypeInfo Get(Type contractInterface, ReadOnlySpan<Type> addition | |
| string rpcMethodName = methodNameMap.GetRpcMethodName(method); | ||
| if (rpcInterfaceCode.HasValue) | ||
| { | ||
| methodName = rpcInterfaceCode + "." + method.Name; | ||
| rpcMethodName = rpcInterfaceCode + "." + rpcMethodName; | ||
| methodName = $"{rpcInterfaceCode.GetValueOrDefault()}.{method.Name}"; | ||
| rpcMethodName = $"{rpcInterfaceCode.GetValueOrDefault()}.{rpcMethodName}"; | ||
| } | ||
|
Comment on lines
295
to
299
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (rpcInterfaceCode is { } localRpcInterfaceCode)
{
methodName = $"{localRpcInterfaceCode}.{method.Name}";
rpcMethodName = $"{localRpcInterfaceCode}.{rpcMethodName}";
}/cc @stephentoub 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or why not just: if (rpcInterfaceCode.HasValue)
{
methodName = $"{rpcInterfaceCode}.{method.Name}";
rpcMethodName = $"{rpcInterfaceCode}.{rpcMethodName}";
}There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the latter, just because nullable value types are a bit less efficient in interpolated strings. Probably not a big deal, though. For the former, seems like a stylistic preference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's exactly the same code, but more CSharpy. 😄 It just shows you were used to doing the right thing before C# had pattern matching. 😄 |
||
|
|
||
| ParameterInfo[] methodParameters = method.GetParameters(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.