-
-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #891 from Cysharp/feature/UpgradeLangVersion
Upgrade LangVersion
- Loading branch information
Showing
80 changed files
with
7,264 additions
and
7,543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
using Grpc.Core; | ||
using MessagePack; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Grpc.Core; | ||
|
||
namespace MagicOnion.Client | ||
namespace MagicOnion.Client; | ||
|
||
public interface IResponseContext : IDisposable | ||
{ | ||
public interface IResponseContext : IDisposable | ||
{ | ||
Task<Metadata> ResponseHeadersAsync { get; } | ||
Status GetStatus(); | ||
Metadata GetTrailers(); | ||
Type ResponseType { get; } | ||
} | ||
Task<Metadata> ResponseHeadersAsync { get; } | ||
Status GetStatus(); | ||
Metadata GetTrailers(); | ||
Type ResponseType { get; } | ||
} | ||
|
||
public interface IResponseContext<T> : IResponseContext | ||
{ | ||
Task<T> ResponseAsync { get; } | ||
} | ||
public interface IResponseContext<T> : IResponseContext | ||
{ | ||
Task<T> ResponseAsync { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,86 @@ | ||
using Grpc.Core; | ||
using MessagePack; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MagicOnion.Internal; | ||
|
||
namespace MagicOnion | ||
namespace MagicOnion; | ||
|
||
/// <summary> | ||
/// Wrapped AsyncClientStreamingCall. | ||
/// </summary> | ||
public struct ClientStreamingResult<TRequest, TResponse> : IDisposable | ||
{ | ||
/// <summary> | ||
/// Wrapped AsyncClientStreamingCall. | ||
/// </summary> | ||
public struct ClientStreamingResult<TRequest, TResponse> : IDisposable | ||
{ | ||
internal readonly TResponse? rawValue; | ||
internal readonly bool hasRawValue; | ||
readonly IAsyncClientStreamingCallWrapper<TRequest, TResponse>? inner; | ||
internal readonly TResponse? rawValue; | ||
internal readonly bool hasRawValue; | ||
readonly IAsyncClientStreamingCallWrapper<TRequest, TResponse>? inner; | ||
|
||
public ClientStreamingResult(TResponse rawValue) | ||
{ | ||
this.hasRawValue = true; | ||
this.rawValue = rawValue; | ||
this.inner = null; | ||
} | ||
public ClientStreamingResult(TResponse rawValue) | ||
{ | ||
this.hasRawValue = true; | ||
this.rawValue = rawValue; | ||
this.inner = null; | ||
} | ||
|
||
public ClientStreamingResult(IAsyncClientStreamingCallWrapper<TRequest, TResponse> inner) | ||
{ | ||
this.hasRawValue = false; | ||
this.rawValue = default(TResponse); | ||
this.inner = inner; | ||
} | ||
public ClientStreamingResult(IAsyncClientStreamingCallWrapper<TRequest, TResponse> inner) | ||
{ | ||
this.hasRawValue = false; | ||
this.rawValue = default(TResponse); | ||
this.inner = inner; | ||
} | ||
|
||
IAsyncClientStreamingCallWrapper<TRequest, TResponse> GetRequiredInner() | ||
=> inner ?? throw new NotSupportedException("ClientStreamingResult has no inner stream."); | ||
IAsyncClientStreamingCallWrapper<TRequest, TResponse> GetRequiredInner() | ||
=> inner ?? throw new NotSupportedException("ClientStreamingResult has no inner stream."); | ||
|
||
/// <summary> | ||
/// Asynchronous call result. | ||
/// </summary> | ||
public Task<TResponse> ResponseAsync | ||
=> hasRawValue ? Task.FromResult(rawValue!) : GetRequiredInner().ResponseAsync; | ||
/// <summary> | ||
/// Asynchronous call result. | ||
/// </summary> | ||
public Task<TResponse> ResponseAsync | ||
=> hasRawValue ? Task.FromResult(rawValue!) : GetRequiredInner().ResponseAsync; | ||
|
||
/// <summary> | ||
/// Asynchronous access to response headers. | ||
/// </summary> | ||
public Task<Metadata> ResponseHeadersAsync | ||
=> GetRequiredInner().ResponseHeadersAsync; | ||
/// <summary> | ||
/// Asynchronous access to response headers. | ||
/// </summary> | ||
public Task<Metadata> ResponseHeadersAsync | ||
=> GetRequiredInner().ResponseHeadersAsync; | ||
|
||
/// <summary> | ||
/// Async stream to send streaming requests. | ||
/// </summary> | ||
public IClientStreamWriter<TRequest> RequestStream | ||
=> GetRequiredInner().RequestStream; | ||
/// <summary> | ||
/// Async stream to send streaming requests. | ||
/// </summary> | ||
public IClientStreamWriter<TRequest> RequestStream | ||
=> GetRequiredInner().RequestStream; | ||
|
||
/// <summary> | ||
/// Allows awaiting this object directly. | ||
/// </summary> | ||
/// <returns></returns> | ||
public TaskAwaiter<TResponse> GetAwaiter() | ||
{ | ||
return ResponseAsync.GetAwaiter(); | ||
} | ||
/// <summary> | ||
/// Allows awaiting this object directly. | ||
/// </summary> | ||
/// <returns></returns> | ||
public TaskAwaiter<TResponse> GetAwaiter() | ||
{ | ||
return ResponseAsync.GetAwaiter(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the call status if the call has already finished. | ||
/// Throws InvalidOperationException otherwise. | ||
/// </summary> | ||
public Status GetStatus() | ||
=> GetRequiredInner().GetStatus(); | ||
/// <summary> | ||
/// Gets the call status if the call has already finished. | ||
/// Throws InvalidOperationException otherwise. | ||
/// </summary> | ||
public Status GetStatus() | ||
=> GetRequiredInner().GetStatus(); | ||
|
||
/// <summary> | ||
/// Gets the call trailing metadata if the call has already finished. | ||
/// Throws InvalidOperationException otherwise. | ||
/// </summary> | ||
public Metadata GetTrailers() | ||
=> GetRequiredInner().GetTrailers(); | ||
/// <summary> | ||
/// Gets the call trailing metadata if the call has already finished. | ||
/// Throws InvalidOperationException otherwise. | ||
/// </summary> | ||
public Metadata GetTrailers() | ||
=> GetRequiredInner().GetTrailers(); | ||
|
||
/// <summary> | ||
/// Provides means to cleanup after the call. | ||
/// If the call has already finished normally (request stream has been completed and call result has been received), doesn't do anything. | ||
/// Otherwise, requests cancellation of the call which should terminate all pending async operations associated with the call. | ||
/// As a result, all resources being used by the call should be released eventually. | ||
/// </summary> | ||
/// <remarks> | ||
/// Normally, there is no need for you to dispose the call unless you want to utilize the | ||
/// "Cancel" semantics of invoking <c>Dispose</c>. | ||
/// </remarks> | ||
public void Dispose() | ||
=> inner?.Dispose(); | ||
} | ||
/// <summary> | ||
/// Provides means to cleanup after the call. | ||
/// If the call has already finished normally (request stream has been completed and call result has been received), doesn't do anything. | ||
/// Otherwise, requests cancellation of the call which should terminate all pending async operations associated with the call. | ||
/// As a result, all resources being used by the call should be released eventually. | ||
/// </summary> | ||
/// <remarks> | ||
/// Normally, there is no need for you to dispose the call unless you want to utilize the | ||
/// "Cancel" semantics of invoking <c>Dispose</c>. | ||
/// </remarks> | ||
public void Dispose() | ||
=> inner?.Dispose(); | ||
} |
Oops, something went wrong.