Sync shared code from runtime (#24784)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot] 2020-08-11 11:29:32 +00:00 committed by GitHub
parent 3dd75ea18d
commit 6f802812a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 14 deletions

View File

@ -1,22 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
namespace System.Net.Quic.Implementations.MsQuic.Internal
{
internal static class MsQuicStatusCodes
{
internal static readonly uint Success = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Windows.Success : Linux.Success;
internal static readonly uint Pending = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Windows.Pending : Linux.Pending;
internal static readonly uint InternalError = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Windows.InternalError : Linux.InternalError;
internal static uint Success => OperatingSystem.IsWindows() ? Windows.Success : Linux.Success;
internal static uint Pending => OperatingSystem.IsWindows() ? Windows.Pending : Linux.Pending;
internal static uint InternalError => OperatingSystem.IsWindows() ? Windows.InternalError : Linux.InternalError;
// TODO return better error messages here.
public static string GetError(uint status)
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? Windows.GetError(status) : Linux.GetError(status);
}
public static string GetError(uint status) => OperatingSystem.IsWindows() ? Windows.GetError(status) : Linux.GetError(status);
private static class Windows
{

View File

@ -1,20 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
namespace System.Net.Quic.Implementations.MsQuic.Internal
{
internal static class MsQuicStatusHelper
{
internal static bool SuccessfulStatusCode(uint status)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (OperatingSystem.IsWindows())
{
return status < 0x80000000;
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
if (OperatingSystem.IsLinux())
{
return (int)status <= 0;
}