Skip to content

Commit 81976d1

Browse files
BorisDogelias-ik
andauthored
CSHARP-5228: Allow any OS in OperatingSystemHelper (#1511)
Co-authored-by: Elias <[email protected]>
1 parent e4b117b commit 81976d1

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/MongoDB.Driver.Encryption/OperatingSystemHelper.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ internal enum OperatingSystemPlatform
2222
{
2323
Windows,
2424
Linux,
25-
MacOS
25+
MacOS,
26+
Unknown
2627
}
2728

2829
internal static class OperatingSystemHelper
2930
{
3031
public static OperatingSystemPlatform CurrentOperatingSystem => __currentOperatingSystem.Value;
3132

32-
private static readonly Lazy<OperatingSystemPlatform> __currentOperatingSystem = new Lazy<OperatingSystemPlatform>(DetermineOperatingSystemPlatform);
33+
private static readonly Lazy<OperatingSystemPlatform> __currentOperatingSystem = new(DetermineOperatingSystemPlatform);
3334

3435
private static OperatingSystemPlatform DetermineOperatingSystemPlatform()
3536
{
@@ -50,7 +51,7 @@ private static OperatingSystemPlatform DetermineOperatingSystemPlatform()
5051
}
5152
else
5253
{
53-
throw new PlatformNotSupportedException($"Unsupported platform '{RuntimeInformation.OSDescription}'.");
54+
return OperatingSystemPlatform.Unknown;
5455
}
5556
#endif
5657
}

src/MongoDB.Driver/Core/Misc/OperatingSystemHelper.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ internal enum OperatingSystemPlatform
2222
{
2323
Windows,
2424
Linux,
25-
MacOS
25+
MacOS,
26+
Unknown
2627
}
2728

2829
internal static class OperatingSystemHelper
2930
{
3031
public static OperatingSystemPlatform CurrentOperatingSystem => __currentOperatingSystem.Value;
3132

32-
private static readonly Lazy<OperatingSystemPlatform> __currentOperatingSystem = new Lazy<OperatingSystemPlatform>(DetermineOperatingSystemPlatform);
33+
private static readonly Lazy<OperatingSystemPlatform> __currentOperatingSystem = new(DetermineOperatingSystemPlatform);
3334

3435
private static OperatingSystemPlatform DetermineOperatingSystemPlatform()
3536
{
@@ -50,7 +51,7 @@ private static OperatingSystemPlatform DetermineOperatingSystemPlatform()
5051
}
5152
else
5253
{
53-
throw new PlatformNotSupportedException($"Unsupported platform '{RuntimeInformation.OSDescription}'.");
54+
return OperatingSystemPlatform.Unknown;
5455
}
5556
#endif
5657
}

0 commit comments

Comments
 (0)