RuntimeIdentifier.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System.Collections.Generic;
  4. using System.Runtime.InteropServices;
  5. namespace Cli.FunctionalTests
  6. {
  7. // https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
  8. public class RuntimeIdentifier
  9. {
  10. public static RuntimeIdentifier None = new RuntimeIdentifier() {
  11. Name = "none",
  12. OSPlatforms = new[] { OSPlatform.Linux, OSPlatform.OSX, OSPlatform.Windows, },
  13. };
  14. public static RuntimeIdentifier Linux_x64 = new RuntimeIdentifier() {
  15. Name = "linux-x64",
  16. OSPlatforms = new[] { OSPlatform.Linux, },
  17. ExecutableFileExtension = string.Empty,
  18. };
  19. public static RuntimeIdentifier OSX_x64 = new RuntimeIdentifier()
  20. {
  21. Name = "osx-x64",
  22. OSPlatforms = new[] { OSPlatform.OSX, },
  23. ExecutableFileExtension = string.Empty,
  24. };
  25. public static RuntimeIdentifier Win_x64 = new RuntimeIdentifier()
  26. {
  27. Name = "win-x64",
  28. OSPlatforms = new[] { OSPlatform.Windows, },
  29. ExecutableFileExtension = ".exe",
  30. };
  31. public static IEnumerable<RuntimeIdentifier> All = new[]
  32. {
  33. RuntimeIdentifier.None,
  34. RuntimeIdentifier.Linux_x64,
  35. RuntimeIdentifier.OSX_x64,
  36. RuntimeIdentifier.Win_x64,
  37. };
  38. private RuntimeIdentifier() { }
  39. public string Name { get; private set; }
  40. public string RuntimeArgument => (this == None) ? string.Empty : $"--runtime {Name}";
  41. public string Path => (this == None) ? string.Empty : Name;
  42. public IEnumerable<OSPlatform> OSPlatforms { get; private set; }
  43. public string ExecutableFileExtension { get; private set; }
  44. public override string ToString() => Name;
  45. }
  46. }