Skip to content

Commit ab5c259

Browse files
committed
m
1 parent 79b2145 commit ab5c259

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

StandardLibrary/runtimes/java/src/main/java/OsLang/__default.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public static DafnySequence<? extends Character> GetOsShort() {
88
String s = System.getProperty("os.name");
99
if (s.startsWith("Mac OS")) {
1010
s = "MacOS";
11+
} else if (s.startsWith("Linux")) {
12+
s = "Unix";
1113
}
1214
return software.amazon.smithy.dafny.conversion.ToDafny.Simple.CharacterSequence(
1315
s

StandardLibrary/runtimes/net/Extern/OsLang.cs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,32 @@ public partial class __default
1111
// returns one of : MacOS, Windows, Unix, Other
1212
public static icharseq GetOsShort()
1313
{
14-
if (System.OperatingSystem.IsMacOS())
14+
// PlatformID.MacOSX doesn't actually work
15+
String osDesc = System.Runtime.InteropServices.RuntimeInformation.OSDescription;
16+
if (osDesc.Contains("Darwin"))
1517
{
1618
return charseq.FromString("MacOS");
1719
}
18-
if (System.OperatingSystem.IsWindows())
20+
OperatingSystem os = Environment.OSVersion;
21+
PlatformID pid = os.Platform;
22+
switch (pid)
1923
{
20-
return charseq.FromString("Windows");
24+
case PlatformID.Win32NT:
25+
case PlatformID.Win32S:
26+
case PlatformID.Win32Windows:
27+
case PlatformID.WinCE:
28+
return charseq.FromString("Windows");
29+
break;
30+
case PlatformID.Unix:
31+
return charseq.FromString("Unix");
32+
break;
33+
case PlatformID.MacOSX:
34+
return charseq.FromString("MacOS");
35+
break;
36+
default:
37+
return charseq.FromString("Other");
38+
break;
2139
}
22-
if (System.OperatingSystem.IsLinux())
23-
{
24-
return charseq.FromString("Unix");
25-
}
26-
if (System.OperatingSystem.IsFreeBSD())
27-
{
28-
return charseq.FromString("Unix");
29-
}
30-
return charseq.FromString("Other");
3140
}
3241

3342
// returns one of : Java, Dotnet, Go, Python, Rust

0 commit comments

Comments
 (0)