diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d6a15ac40..5a4d98458f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes - The SDK now logs a `Warning` instead of an `Error` when being ratelimited ([#4927](https://github.com/getsentry/sentry-dotnet/pull/4927)) +- libmonosgen and libxamarin frames no longer show as inapp ([#4960](https://github.com/getsentry/sentry-dotnet/pull/4960)) ## 6.2.0-alpha.0 diff --git a/src/Sentry/SentryOptions.cs b/src/Sentry/SentryOptions.cs index 7fc69a600f..cb3aedff78 100644 --- a/src/Sentry/SentryOptions.cs +++ b/src/Sentry/SentryOptions.cs @@ -1904,6 +1904,14 @@ internal static List GetDefaultInAppExclude() => "Grpc", "ServiceStack", "Java.Interop", + // (^|[/\\]) — anchors to start of string or after a forward/backward slash + // ([^/\\]*libmonosgen[^/\\]*) — last segment contains libxamarin (no slashes before/after) + // $ — end of string + new Regex(@"(^|[/\\])([^/\\]*libmonosgen[^/\\]*)$"), + // (^|[/\\]) — anchors to start of string or after a forward/backward slash + // ([^/\\]*libxamarin[^/\\]*) — last segment contains libxamarin (no slashes before/after) + // $ — end of string + new Regex(@"(^|[/\\])([^/\\]*libxamarin[^/\\]*)$") ]; /// diff --git a/test/Sentry.Tests/Protocol/Exceptions/SentryStackFrameTests.cs b/test/Sentry.Tests/Protocol/Exceptions/SentryStackFrameTests.cs index adc2c79526..0e025c4056 100644 --- a/test/Sentry.Tests/Protocol/Exceptions/SentryStackFrameTests.cs +++ b/test/Sentry.Tests/Protocol/Exceptions/SentryStackFrameTests.cs @@ -239,6 +239,46 @@ public void ConfigureAppFrame_WithDefaultOptions_NotBuiltInIgnoredMarkedAsInApp( Assert.True(sut.InApp); } + [Theory] + [InlineData("foolibmonosgenbar", false)] + [InlineData("/data/Containers/Bundle/Application/Example.app/libmonosgen-dotnet-release.dylib", false)] + [InlineData("/data/libmonosgen/something-else.dylib ", true)] + public void ConfigureAppFrame_WithDefaultOptions_ExcludesMonoFrames(string package, bool expectedInApp) + { + var options = new SentryOptions(); + var sut = new SentryStackFrame + { + Function = "async void MainActivity.OnCreate(Bundle savedInstanceState)+(?) =\\u003E { }", + Package = package + }; + + // Act + sut.ConfigureAppFrame(options); + + // Assert + Assert.Equal(sut.InApp, expectedInApp); + } + + [Theory] + [InlineData("foolibxamarinbar", false)] + [InlineData("/data/Containers/Bundle/Application/Example.app/libxamarin-dotnet-release.dylib", false)] + [InlineData("/data/libxamarin/something-else.dylib ", true)] + public void ConfigureAppFrame_WithDefaultOptions_ExcludesXamarinFrames(string package, bool expectedInApp) + { + var options = new SentryOptions(); + var sut = new SentryStackFrame + { + Function = "async void MainActivity.OnCreate(Bundle savedInstanceState)+(?) =\\u003E { }", + Package = package + }; + + // Act + sut.ConfigureAppFrame(options); + + // Assert + Assert.Equal(sut.InApp, expectedInApp); + } + [Fact] public void ConfigureAppFrame_WithDefaultOptions_JavaPackageNotInApp() {