Skip to content

Commit ed20a29

Browse files
committed
yak shaving (code analysis fixes)
1 parent 0cfb34f commit ed20a29

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

src/protobuf-net.Grpc/Internal/ContractOperation.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,11 @@ where method.IsGenericMethodDefinition
316316
{(MethodType.Unary, ResultKind.Sync, VoidKind.Response), nameof(Reshape.UnarySyncVoid) },
317317
};
318318
#pragma warning restore CS0618
319-
private string? GetClientHelperName()
319+
private string? GetClientHelperName() => Context switch
320320
{
321-
switch (Context)
322-
{
323-
case ContextKind.CallContext:
324-
case ContextKind.NoContext:
325-
case ContextKind.CancellationToken:
326-
return _clientResponseMap.TryGetValue((MethodType, Result, Void & VoidKind.Response), out var helper) ? helper : null;
327-
default:
328-
return null;
329-
}
330-
}
321+
ContextKind.CallContext or ContextKind.NoContext or ContextKind.CancellationToken => _clientResponseMap.TryGetValue((MethodType, Result, Void & VoidKind.Response), out var helper) ? helper : null,
322+
_ => null,
323+
};
331324

332325

333326
internal bool IsSyncT()

tests/protobuf-net.Grpc.Test.Integration/StreamTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,10 @@ public async Task FullDuplexAsync(int send, int produce, int stopReadingAfter =
780780
{
781781
await using var svc = CreateClient(out var client);
782782

783-
var reqHeaders = new Metadata();
784-
reqHeaders.Add("produce", produce);
783+
var reqHeaders = new Metadata
784+
{
785+
{ "produce", produce }
786+
};
785787
if (byItem) reqHeaders.Add("mode", "byitem");
786788
if (stopReadingAfter >= 0) reqHeaders.Add("stop", stopReadingAfter);
787789

tests/protobuf-net.Grpc.Test/Issues/Issue87.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ protected override bool TryBind<TService, TRequest, TResponse>(ServiceBindContex
1717
return true;
1818
}
1919
protected internal override void OnWarn(string message, object?[]? args = null)
20-
=> Warnings.Add(string.Format(message, args));
20+
=> Warnings.Add(string.Format(message, args ?? Array.Empty<object>()));
2121
protected internal override void OnError(string message, object?[]? args = null)
22-
=> Errors.Add(string.Format(message, args));
22+
=> Errors.Add(string.Format(message, args ?? Array.Empty<object>()));
2323
}
2424

2525
public class Issue87

0 commit comments

Comments
 (0)