Use OperatingSystem.IsXyz instead of Runtime.IsOSPlatform (#2247)

This commit is contained in:
Jakub Ławreszuk 2024-05-18 20:45:59 +00:00 коммит произвёл GitHub
Родитель f2a97beace
Коммит a1d17845b6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 9 добавлений и 17 удалений

Просмотреть файл

@ -343,15 +343,15 @@ namespace Nerdbank.GitVersioning
/// <returns>Receives the directory that native binaries are expected.</returns>
public static string FindLibGit2NativeBinaries(string basePath)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (OperatingSystem.IsWindows())
{
return Path.Combine(basePath, "lib", "win32", IntPtr.Size == 4 ? "x86" : "x64");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
if (OperatingSystem.IsLinux())
{
return Path.Combine(basePath, "lib", "linux", IntPtr.Size == 4 ? "x86" : "x86_64");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
if (OperatingSystem.IsMacOS())
{
return Path.Combine(basePath, "lib", "osx");
}

Просмотреть файл

@ -117,7 +117,7 @@ namespace Stride.Core.Assets
.GetField("CurrentHost", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
if (currentHostField != null)
{
currentHostField.SetValue(null, Path.Combine(new DirectoryInfo(dotNetSdkPath).Parent.Parent.FullName, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "dotnet.exe" : "dotnet"));
currentHostField.SetValue(null, Path.Combine(new DirectoryInfo(dotNetSdkPath).Parent.Parent.FullName, OperatingSystem.IsWindows() ? "dotnet.exe" : "dotnet"));
}
}

Просмотреть файл

@ -19,24 +19,16 @@ namespace Stride.Core
/// The current running <see cref="PlatformType"/>.
/// </summary>
public static readonly PlatformType Type = PlatformType.UWP;
#elif STRIDE_PLATFORM_ANDROID
/// <summary>
/// The current running <see cref="PlatformType"/>.
/// </summary>
public static readonly PlatformType Type = PlatformType.Android;
#elif STRIDE_PLATFORM_IOS
/// <summary>
/// The current running <see cref="PlatformType"/>.
/// </summary>
public static readonly PlatformType Type = PlatformType.iOS;
#else
/// <summary>
/// The current running <see cref="PlatformType"/>.
/// </summary>
public static readonly PlatformType Type
= RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? PlatformType.Windows
: RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? PlatformType.Linux
: RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? PlatformType.macOS
= OperatingSystem.IsWindows() ? PlatformType.Windows
: OperatingSystem.IsLinux() ? PlatformType.Linux
: OperatingSystem.IsMacOS() ? PlatformType.macOS
: OperatingSystem.IsAndroid() ? PlatformType.Android
: OperatingSystem.IsIOS() ? PlatformType.iOS
: PlatformType.Windows; // For now we use Windows as fallback, but it might be better to throw an exception?
#endif