switch expressions are not supported in unity 2020 (#3178)

This commit is contained in:
Justin Nolan 2022-06-10 15:25:38 +02:00 committed by GitHub
parent d48d59cc08
commit 4b40dea700
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,17 +70,17 @@ static KcpChannel ToKcpChannel(int channel) =>
TransportError ToTransportError(ErrorCode error)
{
return error switch
switch(error)
{
ErrorCode.DnsResolve => TransportError.DnsResolve,
ErrorCode.Timeout => TransportError.Timeout,
ErrorCode.Congestion => TransportError.Congestion,
ErrorCode.InvalidReceive => TransportError.InvalidReceive,
ErrorCode.InvalidSend => TransportError.InvalidSend,
ErrorCode.ConnectionClosed => TransportError.ConnectionClosed,
ErrorCode.Unexpected => TransportError.Unexpected,
_ => throw new InvalidCastException($"KCP: missing error translation for {error}")
};
case ErrorCode.DnsResolve: return TransportError.DnsResolve;
case ErrorCode.Timeout: return TransportError.Timeout;
case ErrorCode.Congestion: return TransportError.Congestion;
case ErrorCode.InvalidReceive: return TransportError.InvalidReceive;
case ErrorCode.InvalidSend: return TransportError.InvalidSend;
case ErrorCode.ConnectionClosed: return TransportError.ConnectionClosed;
case ErrorCode.Unexpected: return TransportError.Unexpected;
default: return throw new InvalidCastException($"KCP: missing error translation for {error}");
}
}
void Awake()