@@ -251,6 +251,8 @@ public class SystemInfo
251251 private static string ? _dockerContainerId ;
252252 private static string ? _osVersion ;
253253 private static string ? _osName ;
254+ private static string ? _osFlavour ;
255+ private static string ? _osCodeName ;
254256 private static bool _isSSH ;
255257 private static Runtimes _runtimes = new Runtimes ( ) ;
256258
@@ -616,7 +618,32 @@ public static string HardwareVendor
616618 }
617619
618620 /// <summary>
619- /// Gets the current Operating System name.
621+ /// Gets a value indicating whether the current OS is Windows
622+ /// </summary>
623+ public static bool IsWindows => RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
624+
625+ /// <summary>
626+ /// Gets a value indicating whether the current OS is Linux
627+ /// </summary>
628+ public static bool IsLinux => RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) ;
629+
630+ /// <summary>
631+ /// Gets a value indicating whether the current OS is macOS
632+ /// </summary>
633+ public static bool IsMacOS => RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ;
634+
635+ /// <summary>
636+ /// Gets a value indicating whether the current OS is FreeBSD
637+ /// </summary>
638+ public static bool IsFreeBSD => RuntimeInformation . IsOSPlatform ( OSPlatform . FreeBSD ) ;
639+
640+ /// <summary>
641+ /// Gets a value indicating whether we are currently running in Docker
642+ /// </summary>
643+ public static bool IsDocker => ExecutionEnvironment == ExecutionEnvironment . Docker ;
644+
645+ /// <summary>
646+ /// Gets the Operating System type. Specifically: Windows, Linux, macOS or FreeBSD.
620647 /// </summary>
621648 public static string OperatingSystem
622649 {
@@ -641,29 +668,20 @@ public static string OperatingSystem
641668 }
642669
643670 /// <summary>
644- /// Gets a value indicating whether the current OS is Windows
645- /// </summary>
646- public static bool IsWindows => RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
647-
648- /// <summary>
649- /// Gets a value indicating whether the current OS is Linux
650- /// </summary>
651- public static bool IsLinux => RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) ;
652-
653- /// <summary>
654- /// Gets a value indicating whether the current OS is macOS
655- /// </summary>
656- public static bool IsMacOS => RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ;
657-
658- /// <summary>
659- /// Gets a value indicating whether the current OS is FreeBSD
671+ /// Gets the actual name of the current Operating System name. eg Windows, Ubuntu, Debian.
660672 /// </summary>
661- public static bool IsFreeBSD => RuntimeInformation . IsOSPlatform ( OSPlatform . FreeBSD ) ;
673+ public static string OperatingSystemName
674+ {
675+ get { return _osFlavour ?? string . Empty ; }
676+ }
662677
663678 /// <summary>
664- /// Gets a value indicating whether we are currently running in Docker
679+ /// Gets the current Operating System code name. eg Redstone, Jammy, Big Sur
665680 /// </summary>
666- public static bool IsDocker => ExecutionEnvironment == ExecutionEnvironment . Docker ;
681+ public static string OperatingSystemCodeName
682+ {
683+ get { return _osCodeName ?? string . Empty ; }
684+ }
667685
668686 /// <summary>
669687 /// Returns the Operating System description, with corrections for Windows 11
@@ -672,26 +690,18 @@ public static string OperatingSystemDescription
672690 {
673691 get
674692 {
675- // WSL is Linux, so this isn't needed since the line below will handle it and do the
676- // same thing. However, it's here because we may want to report this differently.
677- if ( IsWSL )
678- return $ "{ _osName } { _osVersion } ";
679-
680- if ( IsLinux )
681- return $ "{ _osName } { _osVersion } ";
693+ string description ;
694+ if ( OperatingSystemName . StartsWith ( OperatingSystem ) )
695+ description = $ "{ OperatingSystem } ({ OperatingSystem } { OperatingSystemVersion } ";
696+ else
697+ description = $ "{ OperatingSystem } ({ OperatingSystemName } { OperatingSystemVersion } ";
682698
683- if ( IsMacOS )
684- return $ " { _osName } { _osVersion } ";
699+ if ( ! OperatingSystemCodeName . StartsWith ( OperatingSystem ) )
700+ description += $ " \" { OperatingSystemCodeName } \" ";
685701
686- // See https://github.com/getsentry/sentry-dotnet/issues/1484.
687- // C'mon guys: technically the version may be 10.x, but stick to the branding that
688- // the rest of the world understands.
689- if ( IsWindows &&
690- Environment . OSVersion . Version . Major >= 10 &&
691- Environment . OSVersion . Version . Build >= 22000 )
692- return RuntimeInformation . OSDescription . Replace ( "Windows 10." , "Windows 11 version 10." ) ;
702+ description += ")" ;
693703
694- return RuntimeInformation . OSDescription ;
704+ return description ;
695705 }
696706 }
697707
@@ -736,7 +746,7 @@ public static async Task InitializeAsync()
736746
737747 await CheckForWslAsync ( ) . ConfigureAwait ( false ) ;
738748 await GetDockerContainerIdAsync ( ) . ConfigureAwait ( false ) ;
739- await CheckOSVersionNameAsync ( ) . ConfigureAwait ( false ) ;
749+ await GetOsDetailsAsync ( ) . ConfigureAwait ( false ) ;
740750 await CheckForSshAsync ( ) . ConfigureAwait ( false ) ;
741751 await GetcuDNNVersionAsync ( ) . ConfigureAwait ( false ) ;
742752
@@ -765,34 +775,34 @@ public static string GetSystemInfo()
765775 else
766776 info . AppendLine ( $ "System: { SystemName } ") ;
767777
768- info . AppendLine ( $ "Operating System: { OperatingSystem } ( { OperatingSystemDescription } ) ") ;
778+ info . AppendLine ( $ "Operating System: { OperatingSystemDescription } ") ;
769779
770780 if ( CPU is not null )
771781 {
772- var cpus = new StringBuilder ( ) ;
782+ var cpuList = new StringBuilder ( ) ;
773783 if ( ! string . IsNullOrEmpty ( CPU [ 0 ] . Name ) )
774784 {
775- cpus . Append ( CPU [ 0 ] . Name ) ;
785+ cpuList . Append ( CPU [ 0 ] . Name ) ;
776786 if ( ! string . IsNullOrWhiteSpace ( CPU [ 0 ] . HardwareVendor ) )
777- cpus . Append ( $ " ({ CPU [ 0 ] . HardwareVendor } )") ;
778- cpus . Append ( "\n " ) ;
787+ cpuList . Append ( $ " ({ CPU [ 0 ] . HardwareVendor } )") ;
788+ cpuList . Append ( "\n " ) ;
779789 }
780790
781- cpus . Append ( CPU . Count + " CPU" ) ;
791+ cpuList . Append ( CPU . Count + " CPU" ) ;
782792 if ( CPU . Count != 1 )
783- cpus . Append ( "s" ) ;
793+ cpuList . Append ( "s" ) ;
784794
785795 if ( CPU [ 0 ] . NumberOfCores > 0 )
786796 {
787- cpus . Append ( $ " x { CPU [ 0 ] . NumberOfCores } core") ;
797+ cpuList . Append ( $ " x { CPU [ 0 ] . NumberOfCores } core") ;
788798 if ( CPU [ 0 ] . NumberOfCores != 1 )
789- cpus . Append ( "s" ) ;
799+ cpuList . Append ( "s" ) ;
790800 }
791- cpus . Append ( "." ) ;
801+ cpuList . Append ( "." ) ;
792802 if ( CPU [ 0 ] . LogicalProcessors > 0 )
793- cpus . Append ( $ " { CPU [ 0 ] . LogicalProcessors } logical processors") ;
803+ cpuList . Append ( $ " { CPU [ 0 ] . LogicalProcessors } logical processors") ;
794804
795- info . AppendLine ( $ "CPUs: { cpus } ({ Architecture } )") ;
805+ info . AppendLine ( $ "CPUs: { cpuList } ({ Architecture } )") ;
796806 }
797807
798808 if ( ! string . IsNullOrWhiteSpace ( gpuDesc ) )
@@ -1602,7 +1612,7 @@ private static async Task GetMemoryInfoAsync()
16021612
16031613 private static CpuCollection GetCpuInfo ( )
16041614 {
1605- var cpus = new CpuCollection ( ) ;
1615+ var cpuList = new CpuCollection ( ) ;
16061616 if ( _hardwareInfo != null )
16071617 {
16081618 foreach ( var cpu in _hardwareInfo . CpuList )
@@ -1632,15 +1642,15 @@ private static CpuCollection GetCpuInfo()
16321642 else if ( EdgeDevice == "Radxa ROCK" )
16331643 cpuInfo . HardwareVendor = "Rockchip" ;
16341644
1635- cpus . Add ( cpuInfo ) ;
1645+ cpuList . Add ( cpuInfo ) ;
16361646 }
16371647 }
16381648
16391649 // There's obviously at least 1.
1640- if ( cpus . Count == 0 )
1641- cpus . Add ( new CpuInfo ( ) { NumberOfCores = 1 , LogicalProcessors = 1 } ) ;
1650+ if ( cpuList . Count == 0 )
1651+ cpuList . Add ( new CpuInfo ( ) { NumberOfCores = 1 , LogicalProcessors = 1 } ) ;
16421652
1643- return cpus ;
1653+ return cpuList ;
16441654 }
16451655
16461656 private async static Task CheckForWslAsync ( )
@@ -1688,18 +1698,19 @@ private async static Task GetDockerContainerIdAsync()
16881698 }
16891699 }
16901700
1691- private async static Task CheckOSVersionNameAsync ( )
1701+ private async static Task GetOsDetailsAsync ( )
16921702 {
16931703 // Default fallback
16941704 _osName = OperatingSystem ;
1705+ _osFlavour = OperatingSystem ;
16951706 _osVersion = Environment . OSVersion . Version . Major . ToString ( ) ;
16961707
16971708 if ( IsLinux )
16981709 {
16991710 var results = await GetProcessInfoAsync ( "/bin/bash" , "-c \" . /etc/os-release;echo $NAME\" " , null )
17001711 . ConfigureAwait ( false ) ;
17011712 if ( results is not null )
1702- _osName = results [ "output" ] ? . Trim ( ) ; // eg "ubuntu", "debian"
1713+ _osFlavour = results [ "output" ] ? . Trim ( ) ; // eg "ubuntu", "debian"
17031714
17041715 // VERSION_ID is in form "24.10"
17051716 results = await GetProcessInfoAsync ( "/bin/bash" , "-c \" . /etc/os-release;echo $VERSION_ID\" " , null )
@@ -1716,22 +1727,36 @@ private async static Task CheckOSVersionNameAsync()
17161727 {
17171728 string ? name = results [ "name" ] ? . Trim ( ) ; // eg. "Oracular Oriole" for Ubuntu 24.10
17181729 if ( ! string . IsNullOrWhiteSpace ( name ) )
1719- _osName += " (" + name + ")" ;
1730+ _osCodeName = name ;
17201731 }
1721-
17221732 }
17231733 else if ( IsWindows )
17241734 {
1725- if ( Environment . OSVersion . Version . Major >= 10 && Environment . OSVersion . Version . Build >= 22000 )
1726- _osVersion = "11" ;
1735+ _osCodeName = "Windows " + Environment . OSVersion . Version . Major ;
1736+
1737+ if ( Environment . OSVersion . Version . Major >= 10 )
1738+ {
1739+ // See https://github.com/getsentry/sentry-dotnet/issues/1484.
1740+ // C'mon guys: technically the version may be 10.x, but stick to the branding
1741+ // that the rest of the world understands.
1742+ if ( Environment . OSVersion . Version . Build >= 22000 )
1743+ {
1744+ _osVersion = "11" ;
1745+ _osCodeName = "Sun Valley" ;
1746+ }
1747+ else
1748+ {
1749+ _osCodeName = "Redstone" ;
1750+ }
1751+ }
17271752 }
17281753 else if ( IsMacOS )
17291754 {
17301755 string command = "awk '/SOFTWARE LICENSE AGREEMENT FOR macOS/' '/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf' | awk -F 'macOS ' '{print $NF}' | awk '{print substr($0, 0, length($0)-1)}'" ;
17311756 var results = await GetProcessInfoAsync ( "/bin/bash" , $ "-c \" { command } \" ", null )
17321757 . ConfigureAwait ( false ) ;
17331758 if ( results is not null )
1734- _osName = results [ "output" ] ? . Trim ( ) ; // eg. "Big Sur"
1759+ _osCodeName = results [ "output" ] ? . Trim ( ) ; // eg. "Big Sur"
17351760
17361761 results = await GetProcessInfoAsync ( "/bin/bash" , "-c \" sw_vers -productVersion\" " , null )
17371762 . ConfigureAwait ( false ) ;
0 commit comments