From e0b7d268b7546f771e398060771eb063673941ee Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 18 Mar 2026 16:06:58 +0100 Subject: [PATCH 01/15] sync attachments --- src/Sentry/FileAttachmentContent.cs | 10 ++- src/Sentry/IScopeObserver.cs | 10 +++ src/Sentry/Internal/ScopeObserver.cs | 4 ++ .../Platforms/Android/AndroidScopeObserver.cs | 4 ++ .../Platforms/Cocoa/CocoaScopeObserver.cs | 4 ++ src/Sentry/Scope.cs | 15 ++++- test/Sentry.Tests/AttachmentTests.cs | 7 ++ test/Sentry.Tests/ScopeTests.cs | 67 +++++++++++++++++++ 8 files changed, 116 insertions(+), 5 deletions(-) diff --git a/src/Sentry/FileAttachmentContent.cs b/src/Sentry/FileAttachmentContent.cs index 97b60f6de5..252a25d0bc 100644 --- a/src/Sentry/FileAttachmentContent.cs +++ b/src/Sentry/FileAttachmentContent.cs @@ -7,9 +7,13 @@ namespace Sentry; /// public class FileAttachmentContent : IAttachmentContent { - private readonly string _filePath; private readonly bool _readFileAsynchronously; + /// + /// The path to the file to attach. + /// + public string FilePath { get; } + /// /// Creates a new instance of . /// @@ -25,13 +29,13 @@ public FileAttachmentContent(string filePath) : this(filePath, true) /// Whether to use async file I/O to read the file. public FileAttachmentContent(string filePath, bool readFileAsynchronously) { - _filePath = filePath; + FilePath = filePath; _readFileAsynchronously = readFileAsynchronously; } /// public Stream GetStream() => new FileStream( - _filePath, + FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, diff --git a/src/Sentry/IScopeObserver.cs b/src/Sentry/IScopeObserver.cs index 2e8c8ec6ab..870a160a30 100644 --- a/src/Sentry/IScopeObserver.cs +++ b/src/Sentry/IScopeObserver.cs @@ -34,4 +34,14 @@ public interface IScopeObserver /// Sets the current trace /// public void SetTrace(SentryId traceId, SpanId parentSpanId); + + /// + /// Adds an attachment. + /// + public void AddAttachment(SentryAttachment attachment); + + /// + /// Clears all attachments. + /// + public void ClearAttachments(); } diff --git a/src/Sentry/Internal/ScopeObserver.cs b/src/Sentry/Internal/ScopeObserver.cs index feb1411747..3d7862b1eb 100644 --- a/src/Sentry/Internal/ScopeObserver.cs +++ b/src/Sentry/Internal/ScopeObserver.cs @@ -94,4 +94,8 @@ public void SetTrace(SentryId traceId, SpanId parentSpanId) } public abstract void SetTraceImpl(SentryId traceId, SpanId parentSpanId); + + public virtual void AddAttachment(SentryAttachment attachment) { } + + public virtual void ClearAttachments() { } } diff --git a/src/Sentry/Platforms/Android/AndroidScopeObserver.cs b/src/Sentry/Platforms/Android/AndroidScopeObserver.cs index c2a272061f..942115235d 100644 --- a/src/Sentry/Platforms/Android/AndroidScopeObserver.cs +++ b/src/Sentry/Platforms/Android/AndroidScopeObserver.cs @@ -104,4 +104,8 @@ public void SetTrace(SentryId traceId, SpanId parentSpanId) { // TODO: This requires sentry-java 8.4.0 } + + public void AddAttachment(SentryAttachment attachment) { } + + public void ClearAttachments() { } } diff --git a/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs b/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs index d4e7def7a8..461227a138 100644 --- a/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs +++ b/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs @@ -112,4 +112,8 @@ public void SetTrace(SentryId traceId, SpanId parentSpanId) { // TODO: Missing corresponding functionality on the Cocoa SDK } + + public void AddAttachment(SentryAttachment attachment) { } + + public void ClearAttachments() { } } diff --git a/src/Sentry/Scope.cs b/src/Sentry/Scope.cs index 1df554b8ed..b6c54ed016 100644 --- a/src/Sentry/Scope.cs +++ b/src/Sentry/Scope.cs @@ -390,7 +390,14 @@ public void UnsetTag(string key) /// /// Adds an attachment. /// - public void AddAttachment(SentryAttachment attachment) => _attachments.Add(attachment); + public void AddAttachment(SentryAttachment attachment, bool notifyObserver = true) + { + _attachments.Add(attachment); + if (Options.EnableScopeSync && notifyObserver) + { + Options.ScopeObserver?.AddAttachment(attachment); + } + } internal void SetPropagationContext(SentryPropagationContext propagationContext) { @@ -433,6 +440,10 @@ public void ClearAttachments() #else _attachments.Clear(); #endif + if (Options.EnableScopeSync) + { + Options.ScopeObserver?.ClearAttachments(); + } } /// @@ -535,7 +546,7 @@ public void Apply(Scope other) foreach (var attachment in Attachments) { - other.AddAttachment(attachment); + other.AddAttachment(attachment, notifyObserver: false); } } diff --git a/test/Sentry.Tests/AttachmentTests.cs b/test/Sentry.Tests/AttachmentTests.cs index 632238d25b..57c2cc13d2 100644 --- a/test/Sentry.Tests/AttachmentTests.cs +++ b/test/Sentry.Tests/AttachmentTests.cs @@ -2,6 +2,13 @@ namespace Sentry.Tests; public class FileAttachmentContentTests { + [Fact] + public void FilePath_ReturnsConstructorValue() + { + var attachment = new FileAttachmentContent("/some/path/file.txt"); + Assert.Equal("/some/path/file.txt", attachment.FilePath); + } + [Fact] public void DoesNotLock() { diff --git a/test/Sentry.Tests/ScopeTests.cs b/test/Sentry.Tests/ScopeTests.cs index 0bb65dc8ec..4f0a4ec144 100644 --- a/test/Sentry.Tests/ScopeTests.cs +++ b/test/Sentry.Tests/ScopeTests.cs @@ -737,6 +737,73 @@ public void SetTag_NullValue_DoesNotThrowArgumentNullException() Assert.Null(exception); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public void AddAttachment_ObserverExist_ObserverNotifiedIfEnabled(bool enableScopeSync) + { + // Arrange + var observer = Substitute.For(); + var scope = new Scope(new SentryOptions + { + ScopeObserver = observer, + EnableScopeSync = enableScopeSync + }); + var attachment = new SentryAttachment(default, default, default, "test.txt"); + var expectedCount = enableScopeSync ? 1 : 0; + + // Act + scope.AddAttachment(attachment); + + // Assert + observer.Received(expectedCount).AddAttachment(Arg.Is(attachment)); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public void ClearAttachments_ObserverExist_ObserverNotifiedIfEnabled(bool enableScopeSync) + { + // Arrange + var observer = Substitute.For(); + var scope = new Scope(new SentryOptions + { + ScopeObserver = observer, + EnableScopeSync = enableScopeSync + }); + scope.AddAttachment(new SentryAttachment(default, default, default, "test.txt")); + observer.ClearReceivedCalls(); + var expectedCount = enableScopeSync ? 1 : 0; + + // Act + scope.ClearAttachments(); + + // Assert + observer.Received(expectedCount).ClearAttachments(); + } + + [Fact] + public void Apply_Attachments_DoesNotNotifyObserver() + { + // Arrange + var observer = Substitute.For(); + var source = new Scope(new SentryOptions()); + source.AddAttachment(new SentryAttachment(default, default, default, "test.txt")); + + var target = new Scope(new SentryOptions + { + ScopeObserver = observer, + EnableScopeSync = true + }); + observer.ClearReceivedCalls(); + + // Act + source.Apply(target); + + // Assert + observer.DidNotReceive().AddAttachment(Arg.Any()); + } + [Theory] [InlineData(true)] [InlineData(false)] From 53fc737fe4a7c5e89e531a3db08dad8c9f15410b Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 18 Mar 2026 17:19:50 +0100 Subject: [PATCH 02/15] abstract --- src/Sentry/Internal/ScopeObserver.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sentry/Internal/ScopeObserver.cs b/src/Sentry/Internal/ScopeObserver.cs index 3d7862b1eb..8c294638db 100644 --- a/src/Sentry/Internal/ScopeObserver.cs +++ b/src/Sentry/Internal/ScopeObserver.cs @@ -95,7 +95,7 @@ public void SetTrace(SentryId traceId, SpanId parentSpanId) public abstract void SetTraceImpl(SentryId traceId, SpanId parentSpanId); - public virtual void AddAttachment(SentryAttachment attachment) { } + public abstract void AddAttachment(SentryAttachment attachment); - public virtual void ClearAttachments() { } + public abstract void ClearAttachments(); } From 373554804d7c995755866c15da90a5fad8a9c201 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 18 Mar 2026 17:44:56 +0100 Subject: [PATCH 03/15] . --- src/Sentry/Internal/ScopeObserver.cs | 18 ++++++++++++++++-- .../Platforms/Android/AndroidScopeObserver.cs | 12 ++++++++++-- .../Platforms/Cocoa/CocoaScopeObserver.cs | 12 ++++++++++-- .../Platforms/Native/NativeScopeObserver.cs | 10 ++++++++++ 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/Sentry/Internal/ScopeObserver.cs b/src/Sentry/Internal/ScopeObserver.cs index 8c294638db..28f4676f84 100644 --- a/src/Sentry/Internal/ScopeObserver.cs +++ b/src/Sentry/Internal/ScopeObserver.cs @@ -95,7 +95,21 @@ public void SetTrace(SentryId traceId, SpanId parentSpanId) public abstract void SetTraceImpl(SentryId traceId, SpanId parentSpanId); - public abstract void AddAttachment(SentryAttachment attachment); + public void AddAttachment(SentryAttachment attachment) + { + _options.DiagnosticLogger?.Log(SentryLevel.Debug, + "{0} Scope Sync - Adding attachment '{1}'", null, _name, attachment.FileName); + AddAttachmentImpl(attachment); + } + + public abstract void AddAttachmentImpl(SentryAttachment attachment); + + public void ClearAttachments() + { + _options.DiagnosticLogger?.Log( + SentryLevel.Debug, "{0} Scope Sync - Clearing attachments", null, _name); + ClearAttachmentsImpl(); + } - public abstract void ClearAttachments(); + public abstract void ClearAttachmentsImpl(); } diff --git a/src/Sentry/Platforms/Android/AndroidScopeObserver.cs b/src/Sentry/Platforms/Android/AndroidScopeObserver.cs index 942115235d..c78ace2227 100644 --- a/src/Sentry/Platforms/Android/AndroidScopeObserver.cs +++ b/src/Sentry/Platforms/Android/AndroidScopeObserver.cs @@ -105,7 +105,15 @@ public void SetTrace(SentryId traceId, SpanId parentSpanId) // TODO: This requires sentry-java 8.4.0 } - public void AddAttachment(SentryAttachment attachment) { } + public void AddAttachment(SentryAttachment attachment) + { + // TODO: Missing corresponding functionality on the Android SDK + _innerObserver?.AddAttachment(attachment); + } - public void ClearAttachments() { } + public void ClearAttachments() + { + // TODO: Missing corresponding functionality on the Android SDK + _innerObserver?.ClearAttachments(); + } } diff --git a/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs b/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs index 461227a138..b6f805cc34 100644 --- a/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs +++ b/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs @@ -113,7 +113,15 @@ public void SetTrace(SentryId traceId, SpanId parentSpanId) // TODO: Missing corresponding functionality on the Cocoa SDK } - public void AddAttachment(SentryAttachment attachment) { } + public void AddAttachment(SentryAttachment attachment) + { + // TODO: Missing corresponding functionality on the Cocoa SDK + _innerObserver?.AddAttachment(attachment); + } - public void ClearAttachments() { } + public void ClearAttachments() + { + // TODO: Missing corresponding functionality on the Cocoa SDK + _innerObserver?.ClearAttachments(); + } } diff --git a/src/Sentry/Platforms/Native/NativeScopeObserver.cs b/src/Sentry/Platforms/Native/NativeScopeObserver.cs index b278bf1e83..f9034df998 100644 --- a/src/Sentry/Platforms/Native/NativeScopeObserver.cs +++ b/src/Sentry/Platforms/Native/NativeScopeObserver.cs @@ -43,6 +43,16 @@ public override void SetUserImpl(SentryUser user) public override void SetTraceImpl(SentryId traceId, SpanId parentSpanId) => C.sentry_set_trace(traceId.ToString(), parentSpanId.ToString()); + public override void AddAttachmentImpl(SentryAttachment attachment) + { + // TODO: Missing corresponding functionality on the Native SDK + } + + public override void ClearAttachmentsImpl() + { + // TODO: Missing corresponding functionality on the Native SDK + } + private static string GetTimestamp(DateTimeOffset timestamp) => // "o": Using ISO 8601 to make sure the timestamp makes it to the bridge correctly. // https://docs.microsoft.com/en-gb/dotnet/standard/base-types/standard-date-and-time-format-strings#Roundtrip From 2f133179a6f7e3a1f946ac7dc93dd497b0514517 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 19 Mar 2026 11:53:16 +0100 Subject: [PATCH 04/15] bytes --- src/Sentry/ByteAttachmentContent.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Sentry/ByteAttachmentContent.cs b/src/Sentry/ByteAttachmentContent.cs index 56df2bdfda..5db94a1e12 100644 --- a/src/Sentry/ByteAttachmentContent.cs +++ b/src/Sentry/ByteAttachmentContent.cs @@ -5,13 +5,16 @@ namespace Sentry; /// public class ByteAttachmentContent : IAttachmentContent { - private readonly byte[] _bytes; + /// + /// The raw bytes of the attachment. + /// + public byte[] Bytes { get; } /// /// Creates a new instance of . /// - public ByteAttachmentContent(byte[] bytes) => _bytes = bytes; + public ByteAttachmentContent(byte[] bytes) => Bytes = bytes; /// - public Stream GetStream() => new MemoryStream(_bytes); + public Stream GetStream() => new MemoryStream(Bytes); } From c6a86de4bbc76dc72e19e005be6911976bae8abe Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 19 Mar 2026 14:31:48 +0100 Subject: [PATCH 05/15] Update API approval snapshots for ByteAttachmentContent.Bytes --- ...piApprovalTests.Run.DotNet10_0.verified.txt | 18 ++++-------------- ...ApiApprovalTests.Run.DotNet8_0.verified.txt | 18 ++++-------------- ...ApiApprovalTests.Run.DotNet9_0.verified.txt | 18 ++++-------------- .../ApiApprovalTests.Run.Net4_8.verified.txt | 1 + 4 files changed, 13 insertions(+), 42 deletions(-) diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt index 64869d4587..a0c9848a7c 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt @@ -51,6 +51,7 @@ namespace Sentry UnknownError = 1, DisabledHub = 2, EmptyMessage = 3, + DroppedByEventProcessor = 4, } public enum CheckInStatus { @@ -197,7 +198,6 @@ namespace Sentry bool IsSessionActive { get; } Sentry.SentryId LastEventId { get; } Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] Sentry.SentryMetricEmitter Metrics { get; } void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); @@ -806,10 +806,10 @@ namespace Sentry public string? Dsn { get; set; } public bool EnableBackpressureHandling { get; set; } public bool EnableLogs { get; set; } + public bool EnableMetrics { get; set; } public bool EnableScopeSync { get; set; } public bool EnableSpotlight { get; set; } public string? Environment { get; set; } - public Sentry.SentryOptions.ExperimentalSentryOptions Experimental { get; } public System.Collections.Generic.IList FailedRequestStatusCodes { get; set; } public System.Collections.Generic.IList FailedRequestTargets { get; set; } public System.TimeSpan FlushTimeout { get; set; } @@ -894,14 +894,10 @@ namespace Sentry public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSendLog(System.Func beforeSendLog) { } + public void SetBeforeSendMetric(System.Func beforeSendMetric) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public Sentry.SentryOptions UseStackTraceFactory(Sentry.Extensibility.ISentryStackTraceFactory sentryStackTraceFactory) { } - public class ExperimentalSentryOptions - { - public bool EnableMetrics { get; set; } - public void SetBeforeSendMetric(System.Func beforeSendMetric) { } - } } public sealed class SentryPackage : Sentry.ISentryJsonSerializable { @@ -931,11 +927,11 @@ namespace Sentry } public static class SentrySdk { - public static Sentry.SentrySdk.ExperimentalSentrySdk Experimental { get; } public static bool IsEnabled { get; } public static bool IsSessionActive { get; } public static Sentry.SentryId LastEventId { get; } public static Sentry.SentryStructuredLogger Logger { get; } + public static Sentry.SentryMetricEmitter Metrics { get; } public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { } public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public static void AddBreadcrumb(Sentry.Infrastructure.ISystemClock? clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } @@ -995,10 +991,6 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } public static void UnsetTag(string key) { } - public sealed class ExperimentalSentrySdk - { - public Sentry.SentryMetricEmitter Metrics { get; } - } } public class SentrySession : Sentry.ISentrySession { @@ -1490,7 +1482,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void BindClient(Sentry.ISentryClient client) { } public void BindException(System.Exception exception, Sentry.ISpan span) { } @@ -1539,7 +1530,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 64869d4587..a0c9848a7c 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -51,6 +51,7 @@ namespace Sentry UnknownError = 1, DisabledHub = 2, EmptyMessage = 3, + DroppedByEventProcessor = 4, } public enum CheckInStatus { @@ -197,7 +198,6 @@ namespace Sentry bool IsSessionActive { get; } Sentry.SentryId LastEventId { get; } Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] Sentry.SentryMetricEmitter Metrics { get; } void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); @@ -806,10 +806,10 @@ namespace Sentry public string? Dsn { get; set; } public bool EnableBackpressureHandling { get; set; } public bool EnableLogs { get; set; } + public bool EnableMetrics { get; set; } public bool EnableScopeSync { get; set; } public bool EnableSpotlight { get; set; } public string? Environment { get; set; } - public Sentry.SentryOptions.ExperimentalSentryOptions Experimental { get; } public System.Collections.Generic.IList FailedRequestStatusCodes { get; set; } public System.Collections.Generic.IList FailedRequestTargets { get; set; } public System.TimeSpan FlushTimeout { get; set; } @@ -894,14 +894,10 @@ namespace Sentry public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSendLog(System.Func beforeSendLog) { } + public void SetBeforeSendMetric(System.Func beforeSendMetric) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public Sentry.SentryOptions UseStackTraceFactory(Sentry.Extensibility.ISentryStackTraceFactory sentryStackTraceFactory) { } - public class ExperimentalSentryOptions - { - public bool EnableMetrics { get; set; } - public void SetBeforeSendMetric(System.Func beforeSendMetric) { } - } } public sealed class SentryPackage : Sentry.ISentryJsonSerializable { @@ -931,11 +927,11 @@ namespace Sentry } public static class SentrySdk { - public static Sentry.SentrySdk.ExperimentalSentrySdk Experimental { get; } public static bool IsEnabled { get; } public static bool IsSessionActive { get; } public static Sentry.SentryId LastEventId { get; } public static Sentry.SentryStructuredLogger Logger { get; } + public static Sentry.SentryMetricEmitter Metrics { get; } public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { } public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public static void AddBreadcrumb(Sentry.Infrastructure.ISystemClock? clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } @@ -995,10 +991,6 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } public static void UnsetTag(string key) { } - public sealed class ExperimentalSentrySdk - { - public Sentry.SentryMetricEmitter Metrics { get; } - } } public class SentrySession : Sentry.ISentrySession { @@ -1490,7 +1482,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void BindClient(Sentry.ISentryClient client) { } public void BindException(System.Exception exception, Sentry.ISpan span) { } @@ -1539,7 +1530,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index 64869d4587..a0c9848a7c 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -51,6 +51,7 @@ namespace Sentry UnknownError = 1, DisabledHub = 2, EmptyMessage = 3, + DroppedByEventProcessor = 4, } public enum CheckInStatus { @@ -197,7 +198,6 @@ namespace Sentry bool IsSessionActive { get; } Sentry.SentryId LastEventId { get; } Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] Sentry.SentryMetricEmitter Metrics { get; } void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); @@ -806,10 +806,10 @@ namespace Sentry public string? Dsn { get; set; } public bool EnableBackpressureHandling { get; set; } public bool EnableLogs { get; set; } + public bool EnableMetrics { get; set; } public bool EnableScopeSync { get; set; } public bool EnableSpotlight { get; set; } public string? Environment { get; set; } - public Sentry.SentryOptions.ExperimentalSentryOptions Experimental { get; } public System.Collections.Generic.IList FailedRequestStatusCodes { get; set; } public System.Collections.Generic.IList FailedRequestTargets { get; set; } public System.TimeSpan FlushTimeout { get; set; } @@ -894,14 +894,10 @@ namespace Sentry public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSendLog(System.Func beforeSendLog) { } + public void SetBeforeSendMetric(System.Func beforeSendMetric) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public Sentry.SentryOptions UseStackTraceFactory(Sentry.Extensibility.ISentryStackTraceFactory sentryStackTraceFactory) { } - public class ExperimentalSentryOptions - { - public bool EnableMetrics { get; set; } - public void SetBeforeSendMetric(System.Func beforeSendMetric) { } - } } public sealed class SentryPackage : Sentry.ISentryJsonSerializable { @@ -931,11 +927,11 @@ namespace Sentry } public static class SentrySdk { - public static Sentry.SentrySdk.ExperimentalSentrySdk Experimental { get; } public static bool IsEnabled { get; } public static bool IsSessionActive { get; } public static Sentry.SentryId LastEventId { get; } public static Sentry.SentryStructuredLogger Logger { get; } + public static Sentry.SentryMetricEmitter Metrics { get; } public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { } public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public static void AddBreadcrumb(Sentry.Infrastructure.ISystemClock? clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } @@ -995,10 +991,6 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } public static void UnsetTag(string key) { } - public sealed class ExperimentalSentrySdk - { - public Sentry.SentryMetricEmitter Metrics { get; } - } } public class SentrySession : Sentry.ISentrySession { @@ -1490,7 +1482,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void BindClient(Sentry.ISentryClient client) { } public void BindException(System.Exception exception, Sentry.ISpan span) { } @@ -1539,7 +1530,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index fbf517dd1e..33693da406 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -43,6 +43,7 @@ namespace Sentry public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } + public byte[] Bytes { get; } public System.IO.Stream GetStream() { } } public enum CaptureFeedbackResult From 9d8e1fce6519346343d3065a54bcf15a72e6d575 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 19 Mar 2026 15:06:09 +0100 Subject: [PATCH 06/15] Add ByteAttachmentContent.Bytes to API approval snapshots --- test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt | 1 + test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt | 1 + test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt | 1 + 3 files changed, 3 insertions(+) diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt index a0c9848a7c..03d616ed78 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt @@ -43,6 +43,7 @@ namespace Sentry public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } + public byte[] Bytes { get; } public System.IO.Stream GetStream() { } } public enum CaptureFeedbackResult diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index a0c9848a7c..03d616ed78 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -43,6 +43,7 @@ namespace Sentry public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } + public byte[] Bytes { get; } public System.IO.Stream GetStream() { } } public enum CaptureFeedbackResult diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index a0c9848a7c..03d616ed78 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -43,6 +43,7 @@ namespace Sentry public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } + public byte[] Bytes { get; } public System.IO.Stream GetStream() { } } public enum CaptureFeedbackResult From e3bb35b6853354f1097cecb97b171e591ba528e2 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 19 Mar 2026 15:52:01 +0100 Subject: [PATCH 07/15] Reset API approval snapshots to 6.2.0 base, add only ByteAttachmentContent.Bytes --- ...piApprovalTests.Run.DotNet10_0.verified.txt | 18 ++++++++++++++---- ...ApiApprovalTests.Run.DotNet8_0.verified.txt | 18 ++++++++++++++---- ...ApiApprovalTests.Run.DotNet9_0.verified.txt | 18 ++++++++++++++---- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt index 03d616ed78..9492e4cf9b 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt @@ -52,7 +52,6 @@ namespace Sentry UnknownError = 1, DisabledHub = 2, EmptyMessage = 3, - DroppedByEventProcessor = 4, } public enum CheckInStatus { @@ -199,6 +198,7 @@ namespace Sentry bool IsSessionActive { get; } Sentry.SentryId LastEventId { get; } Sentry.SentryStructuredLogger Logger { get; } + [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] Sentry.SentryMetricEmitter Metrics { get; } void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); @@ -807,10 +807,10 @@ namespace Sentry public string? Dsn { get; set; } public bool EnableBackpressureHandling { get; set; } public bool EnableLogs { get; set; } - public bool EnableMetrics { get; set; } public bool EnableScopeSync { get; set; } public bool EnableSpotlight { get; set; } public string? Environment { get; set; } + public Sentry.SentryOptions.ExperimentalSentryOptions Experimental { get; } public System.Collections.Generic.IList FailedRequestStatusCodes { get; set; } public System.Collections.Generic.IList FailedRequestTargets { get; set; } public System.TimeSpan FlushTimeout { get; set; } @@ -895,10 +895,14 @@ namespace Sentry public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSendLog(System.Func beforeSendLog) { } - public void SetBeforeSendMetric(System.Func beforeSendMetric) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public Sentry.SentryOptions UseStackTraceFactory(Sentry.Extensibility.ISentryStackTraceFactory sentryStackTraceFactory) { } + public class ExperimentalSentryOptions + { + public bool EnableMetrics { get; set; } + public void SetBeforeSendMetric(System.Func beforeSendMetric) { } + } } public sealed class SentryPackage : Sentry.ISentryJsonSerializable { @@ -928,11 +932,11 @@ namespace Sentry } public static class SentrySdk { + public static Sentry.SentrySdk.ExperimentalSentrySdk Experimental { get; } public static bool IsEnabled { get; } public static bool IsSessionActive { get; } public static Sentry.SentryId LastEventId { get; } public static Sentry.SentryStructuredLogger Logger { get; } - public static Sentry.SentryMetricEmitter Metrics { get; } public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { } public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public static void AddBreadcrumb(Sentry.Infrastructure.ISystemClock? clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } @@ -992,6 +996,10 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } public static void UnsetTag(string key) { } + public sealed class ExperimentalSentrySdk + { + public Sentry.SentryMetricEmitter Metrics { get; } + } } public class SentrySession : Sentry.ISentrySession { @@ -1483,6 +1491,7 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } + [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void BindClient(Sentry.ISentryClient client) { } public void BindException(System.Exception exception, Sentry.ISpan span) { } @@ -1531,6 +1540,7 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } + [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 03d616ed78..9492e4cf9b 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -52,7 +52,6 @@ namespace Sentry UnknownError = 1, DisabledHub = 2, EmptyMessage = 3, - DroppedByEventProcessor = 4, } public enum CheckInStatus { @@ -199,6 +198,7 @@ namespace Sentry bool IsSessionActive { get; } Sentry.SentryId LastEventId { get; } Sentry.SentryStructuredLogger Logger { get; } + [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] Sentry.SentryMetricEmitter Metrics { get; } void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); @@ -807,10 +807,10 @@ namespace Sentry public string? Dsn { get; set; } public bool EnableBackpressureHandling { get; set; } public bool EnableLogs { get; set; } - public bool EnableMetrics { get; set; } public bool EnableScopeSync { get; set; } public bool EnableSpotlight { get; set; } public string? Environment { get; set; } + public Sentry.SentryOptions.ExperimentalSentryOptions Experimental { get; } public System.Collections.Generic.IList FailedRequestStatusCodes { get; set; } public System.Collections.Generic.IList FailedRequestTargets { get; set; } public System.TimeSpan FlushTimeout { get; set; } @@ -895,10 +895,14 @@ namespace Sentry public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSendLog(System.Func beforeSendLog) { } - public void SetBeforeSendMetric(System.Func beforeSendMetric) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public Sentry.SentryOptions UseStackTraceFactory(Sentry.Extensibility.ISentryStackTraceFactory sentryStackTraceFactory) { } + public class ExperimentalSentryOptions + { + public bool EnableMetrics { get; set; } + public void SetBeforeSendMetric(System.Func beforeSendMetric) { } + } } public sealed class SentryPackage : Sentry.ISentryJsonSerializable { @@ -928,11 +932,11 @@ namespace Sentry } public static class SentrySdk { + public static Sentry.SentrySdk.ExperimentalSentrySdk Experimental { get; } public static bool IsEnabled { get; } public static bool IsSessionActive { get; } public static Sentry.SentryId LastEventId { get; } public static Sentry.SentryStructuredLogger Logger { get; } - public static Sentry.SentryMetricEmitter Metrics { get; } public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { } public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public static void AddBreadcrumb(Sentry.Infrastructure.ISystemClock? clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } @@ -992,6 +996,10 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } public static void UnsetTag(string key) { } + public sealed class ExperimentalSentrySdk + { + public Sentry.SentryMetricEmitter Metrics { get; } + } } public class SentrySession : Sentry.ISentrySession { @@ -1483,6 +1491,7 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } + [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void BindClient(Sentry.ISentryClient client) { } public void BindException(System.Exception exception, Sentry.ISpan span) { } @@ -1531,6 +1540,7 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } + [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index 03d616ed78..9492e4cf9b 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -52,7 +52,6 @@ namespace Sentry UnknownError = 1, DisabledHub = 2, EmptyMessage = 3, - DroppedByEventProcessor = 4, } public enum CheckInStatus { @@ -199,6 +198,7 @@ namespace Sentry bool IsSessionActive { get; } Sentry.SentryId LastEventId { get; } Sentry.SentryStructuredLogger Logger { get; } + [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] Sentry.SentryMetricEmitter Metrics { get; } void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); @@ -807,10 +807,10 @@ namespace Sentry public string? Dsn { get; set; } public bool EnableBackpressureHandling { get; set; } public bool EnableLogs { get; set; } - public bool EnableMetrics { get; set; } public bool EnableScopeSync { get; set; } public bool EnableSpotlight { get; set; } public string? Environment { get; set; } + public Sentry.SentryOptions.ExperimentalSentryOptions Experimental { get; } public System.Collections.Generic.IList FailedRequestStatusCodes { get; set; } public System.Collections.Generic.IList FailedRequestTargets { get; set; } public System.TimeSpan FlushTimeout { get; set; } @@ -895,10 +895,14 @@ namespace Sentry public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSendLog(System.Func beforeSendLog) { } - public void SetBeforeSendMetric(System.Func beforeSendMetric) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public Sentry.SentryOptions UseStackTraceFactory(Sentry.Extensibility.ISentryStackTraceFactory sentryStackTraceFactory) { } + public class ExperimentalSentryOptions + { + public bool EnableMetrics { get; set; } + public void SetBeforeSendMetric(System.Func beforeSendMetric) { } + } } public sealed class SentryPackage : Sentry.ISentryJsonSerializable { @@ -928,11 +932,11 @@ namespace Sentry } public static class SentrySdk { + public static Sentry.SentrySdk.ExperimentalSentrySdk Experimental { get; } public static bool IsEnabled { get; } public static bool IsSessionActive { get; } public static Sentry.SentryId LastEventId { get; } public static Sentry.SentryStructuredLogger Logger { get; } - public static Sentry.SentryMetricEmitter Metrics { get; } public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { } public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public static void AddBreadcrumb(Sentry.Infrastructure.ISystemClock? clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } @@ -992,6 +996,10 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } public static void UnsetTag(string key) { } + public sealed class ExperimentalSentrySdk + { + public Sentry.SentryMetricEmitter Metrics { get; } + } } public class SentrySession : Sentry.ISentrySession { @@ -1483,6 +1491,7 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } + [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void BindClient(Sentry.ISentryClient client) { } public void BindException(System.Exception exception, Sentry.ISpan span) { } @@ -1531,6 +1540,7 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } + [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } From 62c60872ca5b039db9373975f9f489a098c441af Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 19 Mar 2026 16:11:55 +0100 Subject: [PATCH 08/15] Update API approval snapshots with all branch changes --- .../ApiApprovalTests.Run.DotNet10_0.verified.txt | 5 ++++- .../Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt | 5 ++++- .../Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt | 5 ++++- test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt index 9492e4cf9b..ceae2fa6b6 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt @@ -108,6 +108,7 @@ namespace Sentry { public FileAttachmentContent(string filePath) { } public FileAttachmentContent(string filePath, bool readFileAsynchronously) { } + public string FilePath { get; } public System.IO.Stream GetStream() { } } public static class HasExtraExtensions @@ -218,7 +219,9 @@ namespace Sentry } public interface IScopeObserver { + void AddAttachment(Sentry.SentryAttachment attachment); void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); + void ClearAttachments(); void SetExtra(string key, object? value); void SetTag(string key, string value); void SetTrace(Sentry.SentryId traceId, Sentry.SpanId parentSpanId); @@ -393,7 +396,7 @@ namespace Sentry public Sentry.ITransactionTracer? Transaction { get; set; } public string? TransactionName { get; set; } public Sentry.SentryUser User { get; set; } - public void AddAttachment(Sentry.SentryAttachment attachment) { } + public void AddAttachment(Sentry.SentryAttachment attachment, bool notifyObserver = true) { } public void AddAttachment(string filePath, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(System.IO.Stream stream, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(byte[] data, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 9492e4cf9b..ceae2fa6b6 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -108,6 +108,7 @@ namespace Sentry { public FileAttachmentContent(string filePath) { } public FileAttachmentContent(string filePath, bool readFileAsynchronously) { } + public string FilePath { get; } public System.IO.Stream GetStream() { } } public static class HasExtraExtensions @@ -218,7 +219,9 @@ namespace Sentry } public interface IScopeObserver { + void AddAttachment(Sentry.SentryAttachment attachment); void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); + void ClearAttachments(); void SetExtra(string key, object? value); void SetTag(string key, string value); void SetTrace(Sentry.SentryId traceId, Sentry.SpanId parentSpanId); @@ -393,7 +396,7 @@ namespace Sentry public Sentry.ITransactionTracer? Transaction { get; set; } public string? TransactionName { get; set; } public Sentry.SentryUser User { get; set; } - public void AddAttachment(Sentry.SentryAttachment attachment) { } + public void AddAttachment(Sentry.SentryAttachment attachment, bool notifyObserver = true) { } public void AddAttachment(string filePath, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(System.IO.Stream stream, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(byte[] data, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index 9492e4cf9b..ceae2fa6b6 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -108,6 +108,7 @@ namespace Sentry { public FileAttachmentContent(string filePath) { } public FileAttachmentContent(string filePath, bool readFileAsynchronously) { } + public string FilePath { get; } public System.IO.Stream GetStream() { } } public static class HasExtraExtensions @@ -218,7 +219,9 @@ namespace Sentry } public interface IScopeObserver { + void AddAttachment(Sentry.SentryAttachment attachment); void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); + void ClearAttachments(); void SetExtra(string key, object? value); void SetTag(string key, string value); void SetTrace(Sentry.SentryId traceId, Sentry.SpanId parentSpanId); @@ -393,7 +396,7 @@ namespace Sentry public Sentry.ITransactionTracer? Transaction { get; set; } public string? TransactionName { get; set; } public Sentry.SentryUser User { get; set; } - public void AddAttachment(Sentry.SentryAttachment attachment) { } + public void AddAttachment(Sentry.SentryAttachment attachment, bool notifyObserver = true) { } public void AddAttachment(string filePath, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(System.IO.Stream stream, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(byte[] data, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index 33693da406..fb43d6c1e0 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -98,6 +98,7 @@ namespace Sentry { public FileAttachmentContent(string filePath) { } public FileAttachmentContent(string filePath, bool readFileAsynchronously) { } + public string FilePath { get; } public System.IO.Stream GetStream() { } } public static class HasExtraExtensions From 6080ec5fe2f5482733ed2a619b3ba7aa07081f70 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 19 Mar 2026 16:15:17 +0100 Subject: [PATCH 09/15] Make AddAttachment without observer notification internal --- src/Sentry/Scope.cs | 8 +++++--- .../ApiApprovalTests.Run.DotNet10_0.verified.txt | 2 +- .../ApiApprovalTests.Run.DotNet8_0.verified.txt | 2 +- .../ApiApprovalTests.Run.DotNet9_0.verified.txt | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Sentry/Scope.cs b/src/Sentry/Scope.cs index b6c54ed016..e19a697fb2 100644 --- a/src/Sentry/Scope.cs +++ b/src/Sentry/Scope.cs @@ -390,15 +390,17 @@ public void UnsetTag(string key) /// /// Adds an attachment. /// - public void AddAttachment(SentryAttachment attachment, bool notifyObserver = true) + public void AddAttachment(SentryAttachment attachment) { _attachments.Add(attachment); - if (Options.EnableScopeSync && notifyObserver) + if (Options.EnableScopeSync) { Options.ScopeObserver?.AddAttachment(attachment); } } + internal void AddAttachmentWithoutObserver(SentryAttachment attachment) => _attachments.Add(attachment); + internal void SetPropagationContext(SentryPropagationContext propagationContext) { PropagationContext = propagationContext; @@ -546,7 +548,7 @@ public void Apply(Scope other) foreach (var attachment in Attachments) { - other.AddAttachment(attachment, notifyObserver: false); + other.AddAttachmentWithoutObserver(attachment); } } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt index ceae2fa6b6..cbc92e8e9d 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt @@ -396,7 +396,7 @@ namespace Sentry public Sentry.ITransactionTracer? Transaction { get; set; } public string? TransactionName { get; set; } public Sentry.SentryUser User { get; set; } - public void AddAttachment(Sentry.SentryAttachment attachment, bool notifyObserver = true) { } + public void AddAttachment(Sentry.SentryAttachment attachment) { } public void AddAttachment(string filePath, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(System.IO.Stream stream, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(byte[] data, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index ceae2fa6b6..cbc92e8e9d 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -396,7 +396,7 @@ namespace Sentry public Sentry.ITransactionTracer? Transaction { get; set; } public string? TransactionName { get; set; } public Sentry.SentryUser User { get; set; } - public void AddAttachment(Sentry.SentryAttachment attachment, bool notifyObserver = true) { } + public void AddAttachment(Sentry.SentryAttachment attachment) { } public void AddAttachment(string filePath, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(System.IO.Stream stream, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(byte[] data, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index ceae2fa6b6..cbc92e8e9d 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -396,7 +396,7 @@ namespace Sentry public Sentry.ITransactionTracer? Transaction { get; set; } public string? TransactionName { get; set; } public Sentry.SentryUser User { get; set; } - public void AddAttachment(Sentry.SentryAttachment attachment, bool notifyObserver = true) { } + public void AddAttachment(Sentry.SentryAttachment attachment) { } public void AddAttachment(string filePath, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(System.IO.Stream stream, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } public void AddAttachment(byte[] data, string fileName, Sentry.AttachmentType type = 0, string? contentType = null) { } From 767540943dc686675dce6afc024fc661a191565c Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 19 Mar 2026 16:18:00 +0100 Subject: [PATCH 10/15] Remove unused AddAttachmentWithoutObserver method --- src/Sentry/Scope.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Sentry/Scope.cs b/src/Sentry/Scope.cs index e19a697fb2..0adf4a8689 100644 --- a/src/Sentry/Scope.cs +++ b/src/Sentry/Scope.cs @@ -399,8 +399,6 @@ public void AddAttachment(SentryAttachment attachment) } } - internal void AddAttachmentWithoutObserver(SentryAttachment attachment) => _attachments.Add(attachment); - internal void SetPropagationContext(SentryPropagationContext propagationContext) { PropagationContext = propagationContext; @@ -548,7 +546,8 @@ public void Apply(Scope other) foreach (var attachment in Attachments) { - other.AddAttachmentWithoutObserver(attachment); + // Set the attachment directly to avoid triggering a scope sync + _attachments.Add(attachment); } } From d623b57217830955bf7b20b6ffc62d7ed37a76f0 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 19 Mar 2026 16:24:12 +0100 Subject: [PATCH 11/15] Add IScopeObserver attachment methods to Net4_8 snapshot --- test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index fb43d6c1e0..c98205a06f 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -206,7 +206,9 @@ namespace Sentry } public interface IScopeObserver { + void AddAttachment(Sentry.SentryAttachment attachment); void AddBreadcrumb(Sentry.Breadcrumb breadcrumb); + void ClearAttachments(); void SetExtra(string key, object? value); void SetTag(string key, string value); void SetTrace(Sentry.SentryId traceId, Sentry.SpanId parentSpanId); From 43bcbf05ca19ea36ad9bdb21fb2cb52a33506ad2 Mon Sep 17 00:00:00 2001 From: Stefan Jandl Date: Thu, 19 Mar 2026 16:30:41 +0100 Subject: [PATCH 12/15] Apply suggestion from @sentry-warden[bot] Co-authored-by: sentry-warden[bot] <258096371+sentry-warden[bot]@users.noreply.github.com> --- src/Sentry/Scope.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sentry/Scope.cs b/src/Sentry/Scope.cs index 0adf4a8689..8a11e1f975 100644 --- a/src/Sentry/Scope.cs +++ b/src/Sentry/Scope.cs @@ -547,7 +547,7 @@ public void Apply(Scope other) foreach (var attachment in Attachments) { // Set the attachment directly to avoid triggering a scope sync - _attachments.Add(attachment); + other._attachments.Add(attachment); } } From aa0b35375db31bdd3e2f338c9095f824c6c4fb80 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Fri, 20 Mar 2026 09:31:59 +0100 Subject: [PATCH 13/15] tests --- test/Sentry.Tests/AttachmentTests.cs | 24 ++++++++++++ test/Sentry.Tests/ScopeTests.cs | 56 ++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/test/Sentry.Tests/AttachmentTests.cs b/test/Sentry.Tests/AttachmentTests.cs index 57c2cc13d2..95a3666eca 100644 --- a/test/Sentry.Tests/AttachmentTests.cs +++ b/test/Sentry.Tests/AttachmentTests.cs @@ -1,5 +1,29 @@ namespace Sentry.Tests; +public class ByteAttachmentContentTests +{ + [Fact] + public void Bytes_ReturnsConstructorValue() + { + var data = new byte[] { 1, 2, 3 }; + var content = new ByteAttachmentContent(data); + Assert.Same(data, content.Bytes); + } + + [Fact] + public void GetStream_ReturnsBytesContent() + { + var data = new byte[] { 10, 20, 30 }; + var content = new ByteAttachmentContent(data); + + using var stream = content.GetStream(); + using var ms = new MemoryStream(); + stream.CopyTo(ms); + + Assert.Equal(data, ms.ToArray()); + } +} + public class FileAttachmentContentTests { [Fact] diff --git a/test/Sentry.Tests/ScopeTests.cs b/test/Sentry.Tests/ScopeTests.cs index 4f0a4ec144..ccb1b277bf 100644 --- a/test/Sentry.Tests/ScopeTests.cs +++ b/test/Sentry.Tests/ScopeTests.cs @@ -804,6 +804,62 @@ public void Apply_Attachments_DoesNotNotifyObserver() observer.DidNotReceive().AddAttachment(Arg.Any()); } + [Fact] + public void AddAttachment_ByteOverload_NotifiesObserver() + { + // Arrange + var observer = Substitute.For(); + var scope = new Scope(new SentryOptions + { + ScopeObserver = observer, + EnableScopeSync = true + }); + + // Act + scope.AddAttachment(new byte[] { 1, 2, 3 }, "bytes.bin"); + + // Assert + observer.Received(1).AddAttachment(Arg.Is(a => a.FileName == "bytes.bin")); + } + + [Fact] + public void AddAttachment_StreamOverload_NotifiesObserver() + { + // Arrange + var observer = Substitute.For(); + var scope = new Scope(new SentryOptions + { + ScopeObserver = observer, + EnableScopeSync = true + }); + + // Act + scope.AddAttachment(new MemoryStream(new byte[] { 1, 2, 3 }), "stream.bin"); + + // Assert + observer.Received(1).AddAttachment(Arg.Is(a => a.FileName == "stream.bin")); + } + + [Fact] + public void Clear_ObserverExist_NotifiesClearAttachments() + { + // Arrange + var observer = Substitute.For(); + var scope = new Scope(new SentryOptions + { + ScopeObserver = observer, + EnableScopeSync = true + }); + scope.AddAttachment(new SentryAttachment(default, default, default, "test.txt")); + observer.ClearReceivedCalls(); + + // Act + scope.Clear(); + + // Assert + observer.Received(1).ClearAttachments(); + } + [Theory] [InlineData(true)] [InlineData(false)] From bab6d51bb32e4a4929b011bb7c0c43f019b2b3e0 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Fri, 20 Mar 2026 13:37:24 +0100 Subject: [PATCH 14/15] public no more --- src/Sentry/ByteAttachmentContent.cs | 2 +- src/Sentry/FileAttachmentContent.cs | 2 +- test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt | 2 -- test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt | 2 -- test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt | 2 -- test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt | 2 -- 6 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Sentry/ByteAttachmentContent.cs b/src/Sentry/ByteAttachmentContent.cs index 5db94a1e12..31ec59e8b9 100644 --- a/src/Sentry/ByteAttachmentContent.cs +++ b/src/Sentry/ByteAttachmentContent.cs @@ -8,7 +8,7 @@ public class ByteAttachmentContent : IAttachmentContent /// /// The raw bytes of the attachment. /// - public byte[] Bytes { get; } + internal byte[] Bytes { get; } /// /// Creates a new instance of . diff --git a/src/Sentry/FileAttachmentContent.cs b/src/Sentry/FileAttachmentContent.cs index 252a25d0bc..ed3bb4203b 100644 --- a/src/Sentry/FileAttachmentContent.cs +++ b/src/Sentry/FileAttachmentContent.cs @@ -12,7 +12,7 @@ public class FileAttachmentContent : IAttachmentContent /// /// The path to the file to attach. /// - public string FilePath { get; } + internal string FilePath { get; } /// /// Creates a new instance of . diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt index cbc92e8e9d..16cf15b603 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt @@ -43,7 +43,6 @@ namespace Sentry public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } - public byte[] Bytes { get; } public System.IO.Stream GetStream() { } } public enum CaptureFeedbackResult @@ -108,7 +107,6 @@ namespace Sentry { public FileAttachmentContent(string filePath) { } public FileAttachmentContent(string filePath, bool readFileAsynchronously) { } - public string FilePath { get; } public System.IO.Stream GetStream() { } } public static class HasExtraExtensions diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index cbc92e8e9d..16cf15b603 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -43,7 +43,6 @@ namespace Sentry public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } - public byte[] Bytes { get; } public System.IO.Stream GetStream() { } } public enum CaptureFeedbackResult @@ -108,7 +107,6 @@ namespace Sentry { public FileAttachmentContent(string filePath) { } public FileAttachmentContent(string filePath, bool readFileAsynchronously) { } - public string FilePath { get; } public System.IO.Stream GetStream() { } } public static class HasExtraExtensions diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index cbc92e8e9d..16cf15b603 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -43,7 +43,6 @@ namespace Sentry public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } - public byte[] Bytes { get; } public System.IO.Stream GetStream() { } } public enum CaptureFeedbackResult @@ -108,7 +107,6 @@ namespace Sentry { public FileAttachmentContent(string filePath) { } public FileAttachmentContent(string filePath, bool readFileAsynchronously) { } - public string FilePath { get; } public System.IO.Stream GetStream() { } } public static class HasExtraExtensions diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index c98205a06f..93df540504 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -43,7 +43,6 @@ namespace Sentry public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } - public byte[] Bytes { get; } public System.IO.Stream GetStream() { } } public enum CaptureFeedbackResult @@ -98,7 +97,6 @@ namespace Sentry { public FileAttachmentContent(string filePath) { } public FileAttachmentContent(string filePath, bool readFileAsynchronously) { } - public string FilePath { get; } public System.IO.Stream GetStream() { } } public static class HasExtraExtensions From 03254007f3a20d3b5e7c4d3abf32d8341a94d306 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Fri, 20 Mar 2026 13:58:51 +0100 Subject: [PATCH 15/15] try me if you can --- .../Platforms/Android/AndroidScopeObserver.cs | 20 +++++++++++++++---- .../Platforms/Cocoa/CocoaScopeObserver.cs | 20 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/Sentry/Platforms/Android/AndroidScopeObserver.cs b/src/Sentry/Platforms/Android/AndroidScopeObserver.cs index c78ace2227..a05f09c575 100644 --- a/src/Sentry/Platforms/Android/AndroidScopeObserver.cs +++ b/src/Sentry/Platforms/Android/AndroidScopeObserver.cs @@ -107,13 +107,25 @@ public void SetTrace(SentryId traceId, SpanId parentSpanId) public void AddAttachment(SentryAttachment attachment) { - // TODO: Missing corresponding functionality on the Android SDK - _innerObserver?.AddAttachment(attachment); + try + { + // TODO: Missing corresponding functionality on the Android SDK + } + finally + { + _innerObserver?.AddAttachment(attachment); + } } public void ClearAttachments() { - // TODO: Missing corresponding functionality on the Android SDK - _innerObserver?.ClearAttachments(); + try + { + // TODO: Missing corresponding functionality on the Android SDK + } + finally + { + _innerObserver?.ClearAttachments(); + } } } diff --git a/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs b/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs index b6f805cc34..d7a790d8ff 100644 --- a/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs +++ b/src/Sentry/Platforms/Cocoa/CocoaScopeObserver.cs @@ -115,13 +115,25 @@ public void SetTrace(SentryId traceId, SpanId parentSpanId) public void AddAttachment(SentryAttachment attachment) { - // TODO: Missing corresponding functionality on the Cocoa SDK - _innerObserver?.AddAttachment(attachment); + try + { + // TODO: Missing corresponding functionality on the Cocoa SDK + } + finally + { + _innerObserver?.AddAttachment(attachment); + } } public void ClearAttachments() { - // TODO: Missing corresponding functionality on the Cocoa SDK - _innerObserver?.ClearAttachments(); + try + { + // TODO: Missing corresponding functionality on the Cocoa SDK + } + finally + { + _innerObserver?.ClearAttachments(); + } } }