From 404ccd5052ad969e36a1ed56faedcdf9c876e551 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Tue, 3 Nov 2026 14:00:09 +1300 Subject: [PATCH 1/2] fix(maui): CreateElementEventsBreadcrumbs set in code is no longer overwritten BindableSentryMauiOptions.CreateElementEventsBreadcrumbs was initialised to false, so ApplyTo reset the value whenever the key was absent from configuration, clobbering anything set in the UseSentry delegate. Fixes #5859 Co-Authored-By: Claude Opus 5.5 --- src/Sentry.Maui/BindableSentryMauiOptions.cs | 2 +- .../SentryMauiAppBuilderExtensionsTests.cs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Sentry.Maui/BindableSentryMauiOptions.cs b/src/Sentry.Maui/BindableSentryMauiOptions.cs index f4f98e1ad0..fc65f5f2d1 100644 --- a/src/Sentry.Maui/BindableSentryMauiOptions.cs +++ b/src/Sentry.Maui/BindableSentryMauiOptions.cs @@ -8,7 +8,7 @@ internal class BindableSentryMauiOptions : BindableSentryLoggingOptions public bool? IncludeTextInBreadcrumbs { get; set; } public bool? IncludeTitleInBreadcrumbs { get; set; } public bool? IncludeBackgroundingStateInBreadcrumbs { get; set; } - public bool? CreateElementEventsBreadcrumbs { get; set; } = false; + public bool? CreateElementEventsBreadcrumbs { get; set; } public bool? AttachScreenshot { get; set; } public void ApplyTo(SentryMauiOptions options) diff --git a/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs b/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs index 2ea48c1936..b3282e501f 100644 --- a/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs +++ b/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs @@ -270,6 +270,25 @@ public void UseSentry_WithCaching_CanChangeCacheDirectoryPath() Assert.Equal(cachePath, options.CacheDirectoryPath); } + [Fact] + public void UseSentry_CreateElementEventsBreadcrumbsSetInCode_IsNotOverwritten() + { + // Arrange + var builder = _fixture.Builder; + + // Act + builder.UseSentry(options => + { + options.CreateElementEventsBreadcrumbs = true; + }); + + using var app = builder.Build(); + var options = app.Services.GetRequiredService>().Value; + + // Assert + Assert.True(options.CreateElementEventsBreadcrumbs); + } + [Fact] public void UseSentry_DebugFalse_LoggerLeftDefault() { From 5f58ffe9fa9e93ac9f745b548c3f81c3f3fc2f50 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Tue, 3 Nov 2026 22:42:47 +1300 Subject: [PATCH 2/2] test(maui): configure options before UseSentry in regression test On version7 the config binding already runs before the UseSentry callback, so the previous test would stop guarding the fix once main is merged there. Co-Authored-By: Claude Opus 5.5 --- .../SentryMauiAppBuilderExtensionsTests.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs b/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs index b3282e501f..ac5c1bb290 100644 --- a/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs +++ b/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs @@ -275,14 +275,13 @@ public void UseSentry_CreateElementEventsBreadcrumbsSetInCode_IsNotOverwritten() { // Arrange var builder = _fixture.Builder; - - // Act - builder.UseSentry(options => + builder.Services.Configure(options => { options.CreateElementEventsBreadcrumbs = true; }); - using var app = builder.Build(); + // Act + using var app = builder.UseSentry().Build(); var options = app.Services.GetRequiredService>().Value; // Assert