diff --git a/CHANGELOG.md b/CHANGELOG.md index 844ba4106e..8cddfe6a51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Fixed envelopes with oversized attachments getting stuck in __processing ([#3938](https://github.com/getsentry/sentry-dotnet/pull/3938)) - Unknown stack frames in profiles on .NET 8+ ([#3942](https://github.com/getsentry/sentry-dotnet/pull/3942)) - Deduplicate profiling stack frames ([#3941](https://github.com/getsentry/sentry-dotnet/pull/3941)) +- OperatingSystem will now return macOS as OS name instead of 'Darwin' as well as the proper version. ([#2710](https://github.com/getsentry/sentry-dotnet/pull/3956)) - Ignore null value on CocoaScopeObserver.SetTag ([#3948](https://github.com/getsentry/sentry-dotnet/pull/3948)) ## 5.1.0 diff --git a/src/Sentry/Internal/Enricher.cs b/src/Sentry/Internal/Enricher.cs index 54829dca86..3d3629934a 100644 --- a/src/Sentry/Internal/Enricher.cs +++ b/src/Sentry/Internal/Enricher.cs @@ -45,8 +45,15 @@ public void Apply(IEventLike eventLike) } catch { eventLike.Contexts.OperatingSystem.RawDescription = Environment.OSVersion.VersionString; } + #else eventLike.Contexts.OperatingSystem.RawDescription = RuntimeInformation.OSDescription; + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // works for catalyst and net9 base + eventLike.Contexts.OperatingSystem.Name = "macOS"; + eventLike.Contexts.OperatingSystem.Version = Environment.OSVersion.Version.ToString(); // reports macOS version (ie. 15.3.0) + } #endif } } diff --git a/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj b/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj index 24a25093a6..5953b65d70 100644 --- a/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj +++ b/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj @@ -1,7 +1,7 @@  - + $(TargetFrameworks);net8.0-android34.0 $(TargetFrameworks);net8.0-ios17.0 true @@ -65,33 +65,33 @@ - - - + + + - + - - + + - - + + - - + + - - - - + + + + diff --git a/test/Sentry.Tests/EnricherTests.cs b/test/Sentry.Tests/EnricherTests.cs new file mode 100644 index 0000000000..5fd49cdf02 --- /dev/null +++ b/test/Sentry.Tests/EnricherTests.cs @@ -0,0 +1,24 @@ +#if NET6_0_OR_GREATER +using Sentry.Tests; + +namespace Sentry.Maui.Tests; + +public class EnricherTests +{ + [PlatformFact(Platform.MacOS)] + public void macOS_Platform_Version() + { + var elike = Substitute.For(); + elike.Sdk.Returns(new SdkVersion()); + elike.User = new SentryUser(); + elike.Contexts = new SentryContexts(); + + var enricher = new Enricher(new SentryOptions()); + enricher.Apply(elike); + + var os = elike.Contexts.OperatingSystem; + os.Name.Should().Be("macOS"); + os.Version.Should().Be(Environment.OSVersion.Version.ToString()); + } +} +#endif diff --git a/test/Sentry.Tests/PlatformFact.cs b/test/Sentry.Tests/PlatformFact.cs new file mode 100644 index 0000000000..a43fcb5522 --- /dev/null +++ b/test/Sentry.Tests/PlatformFact.cs @@ -0,0 +1,25 @@ +namespace Sentry.Tests; + +public enum Platform +{ + Windows, + Linux, + MacOS +} + +public class PlatformFact : FactAttribute +{ + public PlatformFact(Platform platform) + { + var actual = platform switch + { + Platform.Windows => OSPlatform.Windows, + Platform.Linux => OSPlatform.Linux, + Platform.MacOS => OSPlatform.OSX, + _ => throw new NotSupportedException() + }; + + if (!RuntimeInformation.IsOSPlatform(actual)) + Skip = "Ignored - Not Platform: " + actual; + } +}