Skip to content

Commit ade9bfd

Browse files
Fixed duplicate SentryMauiOptions registration
1 parent b73a294 commit ade9bfd

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public static MauiAppBuilder UseSentry(this MauiAppBuilder builder,
5555
services.AddLogging();
5656
services.AddSingleton<ILoggerProvider, SentryMauiLoggerProvider>();
5757
services.AddSingleton<IMauiInitializeService, SentryMauiInitializer>();
58-
services.AddSingleton<IConfigureOptions<SentryMauiOptions>, SentryMauiOptionsSetup>();
5958
services.AddSingleton<Disposer>();
6059
services.TryAddSingleton<IMauiEventsBinder, MauiEventsBinder>();
6160

test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.Extensions.Options;
22
using Sentry.Internal.Http;
3+
using Sentry.Maui.Internal;
34
using MauiConstants = Sentry.Maui.Internal.Constants;
45

56
namespace Sentry.Maui.Tests;
@@ -29,6 +30,24 @@ public Fixture()
2930

3031
private readonly Fixture _fixture = new();
3132

33+
[Fact]
34+
public void UseSentry_RegistersEventProcessorOnlyOnce()
35+
{
36+
// Arrange
37+
var builder = _fixture.Builder;
38+
builder.Services.Configure<SentryMauiOptions>(options =>
39+
{
40+
options.Dsn = ValidDsn;
41+
});
42+
43+
// Act
44+
using var app = builder.UseSentry().Build();
45+
46+
// Assert
47+
var options = app.Services.GetRequiredService<IOptions<SentryMauiOptions>>().Value;
48+
options.EventProcessors.Should().ContainSingle(t => t.Type == typeof(SentryMauiEventProcessor));
49+
}
50+
3251
[Fact]
3352
public void CanUseSentry_WithConfigurationOnly()
3453
{

0 commit comments

Comments
 (0)