Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
- Fail when building Blazor WASM with Profiling. We don't support profiling in Blazor WebAssembly projects. ([#4512](https://github.com/getsentry/sentry-dotnet/pull/4512))
- Do not overwrite user IP if it is set manually in ASP.NET sdk ([#4513](https://github.com/getsentry/sentry-dotnet/pull/4513))

### Dependencies

- Bump Cocoa SDK from v8.55.1 to v8.56.0 ([#4528](https://github.com/getsentry/sentry-dotnet/pull/4528))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8560)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.55.1...8.56.0)

## 5.15.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion modules/sentry-cocoa.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 8.55.1
version = 8.56.0
repo = https://github.com/getsentry/sentry-cocoa
3 changes: 0 additions & 3 deletions scripts/generate-cocoa-bindings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,6 @@ $Text = $Text -replace '([\[,] )iOS \(', '$1Introduced (PlatformName.iOS, '
# Make interface partial if we need to access private APIs. Other parts will be defined in PrivateApiDefinitions.cs
$Text = $Text -replace '(?m)^interface SentryScope', 'partial $&'

# Prefix SentryBreadcrumb.Serialize and SentryScope.Serialize with new (since these hide the base method)
$Text = $Text -replace '(?m)(^\s*\/\/[^\r\n]*$\s*\[Export \("serialize"\)\]$\s*)(NSDictionary)', '${1}new $2'

$Text = $Text -replace '.*SentryEnvelope .*?[\s\S]*?\n\n', ''
$Text = $Text -replace '.*typedef.*SentryOnAppStartMeasurementAvailable.*?[\s\S]*?\n\n', ''

Expand Down
13 changes: 11 additions & 2 deletions src/Sentry.Bindings.Cocoa/ApiDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ interface SentryBreadcrumb : SentrySerializable

// -(NSDictionary<NSString *,id> * _Nonnull)serialize;
[Export ("serialize")]
new NSDictionary<NSString, NSObject> Serialize();
NSDictionary<NSString, NSObject> Serialize();

// -(BOOL)isEqualToBreadcrumb:(SentryBreadcrumb * _Nonnull)breadcrumb;
[Export ("isEqualToBreadcrumb:")]
Expand Down Expand Up @@ -930,6 +930,11 @@ interface SentrySpan : SentrySerializable
[Abstract]
[NullAllowed, Export ("baggageHttpHeader")]
string BaggageHttpHeader { get; }

// @required -(NSDictionary<NSString *,id> * _Nonnull)serialize;
[Abstract]
[Export ("serialize")]
NSDictionary<NSString, NSObject> Serialize();
}

// @interface SentryHub : NSObject
Expand Down Expand Up @@ -1494,6 +1499,10 @@ interface SentryOptions
[Export ("attachScreenshot")]
bool AttachScreenshot { get; set; }

// @property (nonatomic, strong) SentryViewScreenshotOptions * _Nonnull screenshot;
[Export ("screenshot", ArgumentSemantic.Strong)]
SentryViewScreenshotOptions Screenshot { get; set; }

// @property (assign, nonatomic) BOOL attachViewHierarchy;
[Export ("attachViewHierarchy")]
bool AttachViewHierarchy { get; set; }
Expand Down Expand Up @@ -1864,7 +1873,7 @@ partial interface SentryScope : SentrySerializable

// -(NSDictionary<NSString *,id> * _Nonnull)serialize;
[Export ("serialize")]
new NSDictionary<NSString, NSObject> Serialize();
NSDictionary<NSString, NSObject> Serialize();

// -(void)setContextValue:(NSDictionary<NSString *,id> * _Nonnull)value forKey:(NSString * _Nonnull)key __attribute__((swift_name("setContext(value:key:)")));
[Export ("setContextValue:forKey:")]
Expand Down
7 changes: 0 additions & 7 deletions src/Sentry.Bindings.Cocoa/PrivateApiDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ partial interface SentryScope
// The following types are type-forwarded in various public headers, but have no headers of their own.
// Generate stub classes so the APIs that use them can still operate.

[Internal]
[DisableDefaultCtor]
[BaseType (typeof(NSObject))]
interface SentrySession
{
}

[Internal]
[DisableDefaultCtor]
[BaseType (typeof(NSObject))]
Expand Down
2 changes: 2 additions & 0 deletions src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<SentryCocoaProperties>$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)../../modules/sentry-cocoa.properties"))</SentryCocoaProperties>
<SentryCocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(SentryCocoaProperties), 'version\s*=\s*([^\s]+)').Groups[1].Value)</SentryCocoaVersion>
<SentryCocoaFramework>$(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework</SentryCocoaFramework>
<!-- SentrySpan.g.cs: error CS0108: 'ISentrySpan.Serialize()' hides inherited member 'ISentrySerializable.Serialize()'. Use the new keyword if hiding was intended -->
<NoWarn>$(NoWarn);CS0108</NoWarn>
</PropertyGroup>

<!-- Build empty assemblies when not on macOS, to pass the solution build. -->
Expand Down
132 changes: 132 additions & 0 deletions src/Sentry.Bindings.Cocoa/SwiftApiDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,103 @@ interface SentrySDK
void ClearLogger ();
}

// @interface SentrySession : NSObject <NSCopying>
[BaseType (typeof(NSObject), Name = "_TtC6Sentry13SentrySession")]
[DisableDefaultCtor]
[Internal]
interface SentrySession
{
// -(instancetype _Nonnull)initWithReleaseName:(NSString * _Nonnull)releaseName distinctId:(NSString * _Nonnull)distinctId __attribute__((objc_designated_initializer));
[Export ("initWithReleaseName:distinctId:")]
[DesignatedInitializer]
NativeHandle Constructor (string releaseName, string distinctId);

// -(instancetype _Nullable)initWithJSONObject:(NSDictionary<NSString *,id> * _Nonnull)jsonObject __attribute__((objc_designated_initializer));
[Export ("initWithJSONObject:")]
[DesignatedInitializer]
NativeHandle Constructor (NSDictionary<NSString, NSObject> jsonObject);

// -(void)endSessionExitedWithTimestamp:(NSDate * _Nonnull)timestamp;
[Export ("endSessionExitedWithTimestamp:")]
void EndSessionExitedWithTimestamp (NSDate timestamp);

// -(void)endSessionCrashedWithTimestamp:(NSDate * _Nonnull)timestamp;
[Export ("endSessionCrashedWithTimestamp:")]
void EndSessionCrashedWithTimestamp (NSDate timestamp);

// -(void)endSessionAbnormalWithTimestamp:(NSDate * _Nonnull)timestamp;
[Export ("endSessionAbnormalWithTimestamp:")]
void EndSessionAbnormalWithTimestamp (NSDate timestamp);

// -(void)incrementErrors;
[Export ("incrementErrors")]
void IncrementErrors ();

// @property (readonly, copy, nonatomic) NSUUID * _Nonnull sessionId;
[Export ("sessionId", ArgumentSemantic.Copy)]
NSUuid SessionId { get; }

// @property (readonly, copy, nonatomic) NSDate * _Nonnull started;
[Export ("started", ArgumentSemantic.Copy)]
NSDate Started { get; }

// @property (readonly, nonatomic) enum SentrySessionStatus status;
[Export ("status")]
SentrySessionStatus Status { get; }

// @property (nonatomic) NSUInteger errors;
[Export ("errors")]
nuint Errors { get; set; }

// @property (readonly, nonatomic) NSUInteger sequence;
[Export ("sequence")]
nuint Sequence { get; }

// @property (readonly, copy, nonatomic) NSString * _Nonnull distinctId;
[Export ("distinctId")]
string DistinctId { get; }

// @property (readonly, nonatomic, strong) NSNumber * _Nullable flagInit;
[NullAllowed, Export ("flagInit", ArgumentSemantic.Strong)]
NSNumber FlagInit { get; }

// @property (readonly, copy, nonatomic) NSDate * _Nullable timestamp;
[NullAllowed, Export ("timestamp", ArgumentSemantic.Copy)]
NSDate Timestamp { get; }

// @property (readonly, nonatomic, strong) NSNumber * _Nullable duration;
[NullAllowed, Export ("duration", ArgumentSemantic.Strong)]
NSNumber Duration { get; }

// @property (readonly, copy, nonatomic) NSString * _Nullable releaseName;
[NullAllowed, Export ("releaseName")]
string ReleaseName { get; }

// @property (copy, nonatomic) NSString * _Nullable environment;
[NullAllowed, Export ("environment")]
string Environment { get; set; }

// @property (nonatomic, strong) SentryUser * _Nullable user;
[NullAllowed, Export ("user", ArgumentSemantic.Strong)]
SentryUser User { get; set; }

// @property (copy, nonatomic) NSString * _Nullable abnormalMechanism;
[NullAllowed, Export ("abnormalMechanism")]
string AbnormalMechanism { get; set; }

// -(NSDictionary<NSString *,id> * _Nonnull)serialize __attribute__((warn_unused_result("")));
[Export ("serialize")]
NSDictionary<NSString, NSObject> Serialize();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question new/CS0108

Why can't (or shouldn't) use new here (and in ApiDefinitions.cs),
and rather suppress the diagnostic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And should we, consequently, also remove the other usages of new?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was that the error came from SentrySpan.g.cs, not from ApiDefinitions.cs:

Error: /Users/runner/work/sentry-dotnet/sentry-dotnet/src/Sentry.Bindings.Cocoa/obj/Release/net8.0-ios17.0/iOS/Sentry.CocoaSdk/SentrySpan.g.cs(134,36): error CS0108: 'ISentrySpan.Serialize()' hides inherited member 'ISentrySerializable.Serialize()'. Use the new keyword if hiding was intended. [/Users/runner/work/sentry-dotnet/sentry-dotnet/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj::TargetFramework=net8.0-ios17.0]

https://github.com/getsentry/sentry-dotnet/actions/runs/17763516547/job/50481482686?pr=4528

Is there any other way to get around this? If not, we could indeed remove the respective modifications in ApiDefinitions.cs.

Copy link
Collaborator

@jpnurmi jpnurmi Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to elaborate a bit, I had tried changing the regexp to make ApiDefinitions.cs look like this:

// @protocol SentrySpan <SentrySerializable>
[Protocol]
[Model]
[Internal]
[BaseType (typeof(NSObject))]
interface SentrySpan : SentrySerializable
{
    ...

    // @required -(NSDictionary<NSString *,id> * _Nonnull)serialize;
    [Abstract]
    [Export ("serialize")]
    new NSDictionary<NSString, NSObject> Serialize();
}

Still, SentrySpan.g.cs generated on the fly looks like this:

namespace Sentry.CocoaSdk {
	...
	internal partial interface ISentrySpan : INativeObject, IDisposable, 
		Sentry.CocoaSdk.ISentrySerializable
	{
		...
		[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
		[Export ("serialize")]
		[Preserve (Conditional = true)]
		NSDictionary<NSString, NSObject> Serialize ();
}

Which then results in CS0108 :(

  Sentry.Bindings.Cocoa net8.0-maccatalyst17.0 failed with 1 error(s) (6.2s)
    /Users/jpnurmi/Projects/sentry/sentry-dotnet/src/Sentry.Bindings.Cocoa/obj/Release/net8.0-maccatalyst17.0/MacCatalyst/Sentry.CocoaSdk/SentrySpan.g.cs(134,36): error CS0108: 'ISentrySpan.Serialize()' hides inherited member 'ISentrySerializable.Serialize()'. Use the new keyword if hiding was intended.
  Sentry.Bindings.Cocoa net8.0-ios17.0 failed with 1 error(s) (6.8s)
    /Users/jpnurmi/Projects/sentry/sentry-dotnet/src/Sentry.Bindings.Cocoa/obj/Release/net8.0-ios17.0/iOS/Sentry.CocoaSdk/SentrySpan.g.cs(134,36): error CS0108: 'ISentrySpan.Serialize()' hides inherited member 'ISentrySerializable.Serialize()'. Use the new keyword if hiding was intended.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cleaned up the unnecessary modifications now that CS0108 is disabled: e7b1919

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you ignore the CS0108 warning and do not use the new keyword, the runtime behavior is identical to what it would be if you had used new. The new keyword only affects compile-time intent and clarity, not the actual method hiding at runtime.

  • Without new: The member still hides the base member, but the compiler warns you (CS0108) to make sure you’re aware.
  • With new: The member explicitly hides the base member, and the warning is suppressed.

In both cases, the derived member hides the base member, and calls to the member on the derived type will use the derived implementation. The difference is only at compile time: using new makes your intent explicit and silences the warning.

Summary:
Ignoring the warning does not change runtime behavior; it only leaves a warning in your build output. The code will work the same way either way.

Copy link
Member

@Flash0ver Flash0ver Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see ... thanks for elaborating.
Now I'm wondering, does new actually have an effect in metadata ... so I'm wondering of removing existing news could be a breaking change 🤔 ... so I'm wondering if we should leave it as it was before my "complaint"

UPDATE 1: no ... new does not seem to be reflected in IL
UPDATE 2: oops ... didn't see your latest comment ... I have no more concerns 😉

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe safer to leave the existing ones intact, after all?


// -(void)setFlagInit;
[Export ("setFlagInit")]
void SetFlagInit ();

// -(id _Nonnull)copyWithZone:(struct _NSZone * _Nullable)zone __attribute__((warn_unused_result("")));
// [Export ("copyWithZone:")]
// unsafe NSObject CopyWithZone ([NullAllowed] _NSZone* zone);
}

// @interface SentryUserFeedback : NSObject <SentrySerializable>
[BaseType(typeof(NSObject))]
[DisableDefaultCtor]
Expand Down Expand Up @@ -750,6 +847,41 @@ interface SentryUserFeedbackWidgetConfiguration
// IntPtr Constructor();
// }

// @interface SentryViewScreenshotOptions : NSObject <SentryRedactOptions>
[BaseType (typeof(NSObject), Name = "_TtC6Sentry27SentryViewScreenshotOptions")]
[Internal]
interface SentryViewScreenshotOptions //: ISentryRedactOptions
{
// @property (nonatomic) BOOL enableViewRendererV2;
[Export ("enableViewRendererV2")]
bool EnableViewRendererV2 { get; set; }

// @property (nonatomic) BOOL enableFastViewRendering;
[Export ("enableFastViewRendering")]
bool EnableFastViewRendering { get; set; }

// @property (nonatomic) BOOL maskAllImages;
[Export ("maskAllImages")]
bool MaskAllImages { get; set; }

// @property (nonatomic) BOOL maskAllText;
[Export ("maskAllText")]
bool MaskAllText { get; set; }

// @property (copy, nonatomic) NSArray<Class> * _Nonnull maskedViewClasses;
[Export ("maskedViewClasses", ArgumentSemantic.Copy)]
Class[] MaskedViewClasses { get; set; }

// @property (copy, nonatomic) NSArray<Class> * _Nonnull unmaskedViewClasses;
[Export ("unmaskedViewClasses", ArgumentSemantic.Copy)]
Class[] UnmaskedViewClasses { get; set; }

// -(instancetype _Nonnull)initWithEnableViewRendererV2:(BOOL)enableViewRendererV2 enableFastViewRendering:(BOOL)enableFastViewRendering maskAllText:(BOOL)maskAllText maskAllImages:(BOOL)maskAllImages maskedViewClasses:(NSArray<Class> * _Nonnull)maskedViewClasses unmaskedViewClasses:(NSArray<Class> * _Nonnull)unmaskedViewClasses __attribute__((objc_designated_initializer));
[Export ("initWithEnableViewRendererV2:enableFastViewRendering:maskAllText:maskAllImages:maskedViewClasses:unmaskedViewClasses:")]
[DesignatedInitializer]
NativeHandle Constructor (bool enableViewRendererV2, bool enableFastViewRendering, bool maskAllText, bool maskAllImages, Class[] maskedViewClasses, Class[] unmaskedViewClasses);
}

// @protocol SentryViewScreenshotProvider <NSObject>
[Protocol (Name = "_TtP6Sentry28SentryViewScreenshotProvider_")]
[Model]
Expand Down
9 changes: 9 additions & 0 deletions src/Sentry.Bindings.Cocoa/SwiftStructsAndEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ internal enum SentryRRWebEventType : long
Custom = 5
}

[Native]
internal enum SentrySessionStatus : ulong
{
Ok = 0,
Exited = 1,
Crashed = 2,
Abnormal = 3
}

[Native]
internal enum SentryTransactionNameSource : long
{
Expand Down
Loading