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:
parent
3dd75ea18d
commit
6f802812a3
|
|
@ -1,22 +1,16 @@
|
||||||
// Licensed to the .NET Foundation under one or more agreements.
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||||
// The .NET Foundation licenses this file to you under the MIT license.
|
// The .NET Foundation licenses this file to you under the MIT license.
|
||||||
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace System.Net.Quic.Implementations.MsQuic.Internal
|
namespace System.Net.Quic.Implementations.MsQuic.Internal
|
||||||
{
|
{
|
||||||
internal static class MsQuicStatusCodes
|
internal static class MsQuicStatusCodes
|
||||||
{
|
{
|
||||||
internal static readonly uint Success = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Windows.Success : Linux.Success;
|
internal static uint Success => OperatingSystem.IsWindows() ? Windows.Success : Linux.Success;
|
||||||
internal static readonly uint Pending = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Windows.Pending : Linux.Pending;
|
internal static uint Pending => OperatingSystem.IsWindows() ? Windows.Pending : Linux.Pending;
|
||||||
internal static readonly uint InternalError = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Windows.InternalError : Linux.InternalError;
|
internal static uint InternalError => OperatingSystem.IsWindows() ? Windows.InternalError : Linux.InternalError;
|
||||||
|
|
||||||
// TODO return better error messages here.
|
// TODO return better error messages here.
|
||||||
public static string GetError(uint status)
|
public static string GetError(uint status) => OperatingSystem.IsWindows() ? Windows.GetError(status) : Linux.GetError(status);
|
||||||
{
|
|
||||||
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
|
||||||
? Windows.GetError(status) : Linux.GetError(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Windows
|
private static class Windows
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,18 @@
|
||||||
// Licensed to the .NET Foundation under one or more agreements.
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||||
// The .NET Foundation licenses this file to you under the MIT license.
|
// The .NET Foundation licenses this file to you under the MIT license.
|
||||||
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace System.Net.Quic.Implementations.MsQuic.Internal
|
namespace System.Net.Quic.Implementations.MsQuic.Internal
|
||||||
{
|
{
|
||||||
internal static class MsQuicStatusHelper
|
internal static class MsQuicStatusHelper
|
||||||
{
|
{
|
||||||
internal static bool SuccessfulStatusCode(uint status)
|
internal static bool SuccessfulStatusCode(uint status)
|
||||||
{
|
{
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (OperatingSystem.IsWindows())
|
||||||
{
|
{
|
||||||
return status < 0x80000000;
|
return status < 0x80000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
if (OperatingSystem.IsLinux())
|
||||||
{
|
{
|
||||||
return (int)status <= 0;
|
return (int)status <= 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue