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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ scripts/ # Build and maintenance scripts
- **macOS only**. Requires Xcode.
- `Sentry.Bindings.Cocoa` wraps the native Cocoa SDK.
- Device tests run in CI only.
- `src/Sentry.Bindings.Cocoa/ApiDefinitions.cs` and `StructsAndEnums.cs` are **auto-generated** — do not edit them directly. All changes must go in `scripts/patch-cocoa-bindings.cs` and be applied by running `scripts/generate-cocoa-bindings.ps1`.

### MAUI
- Requires MAUI workloads: `sudo dotnet workload restore` (macOS/Linux) or `dotnet workload restore` (Windows).
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 = 9.7.0
version = 9.8.0
repo = https://github.com/getsentry/sentry-cocoa
28 changes: 28 additions & 0 deletions scripts/patch-cocoa-bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
.RemoveAttribute("PrivateSentrySDKOnly", "CaptureViewHierarchy", "NullAllowed")
.WithAttribute("PrivateSentrySDKOnly", "CaptureScreenshots", "return: NullAllowed")
.WithAttribute("PrivateSentrySDKOnly", "CaptureViewHierarchy", "return: NullAllowed")
// Fix nullable property attributes
.WithPropertyAttribute("SentryOptions", "OnCrashedLastRun", "NullAllowed")
// Fix nullable generic type arguments
.ChangePropertyType("SentryOptions", "OnLastRunStatusDetermined", "Action<SentryLastRunStatus, SentryEvent?>")
// For PrivateApiDefinitions.cs
.WithModifier("SentryScope", "partial")
// error CS0246: The type or namespace name 'iOS' could not be found
Expand Down Expand Up @@ -309,6 +313,30 @@ public static CompilationUnitSyntax WithAttribute(
return root.ReplaceNodes(nodes, (node, _) => node.WithAttribute(attribute));
}

public static CompilationUnitSyntax WithPropertyAttribute(
this CompilationUnitSyntax root,
string type,
string name,
string attribute)
{
var nodes = root.DescendantNodes()
.OfType<PropertyDeclarationSyntax>()
.Where(node => node.Identifier.Matches(name) && node.HasParent(type) && !node.HasAttribute(attribute));
return root.ReplaceNodes(nodes, (node, _) =>
{
var newAttr = SyntaxFactory.Attribute(SyntaxFactory.IdentifierName(attribute));
if (node.AttributeLists.Count > 0)
{
// Prepend into the first existing attribute list (e.g. [NullAllowed, Export(...)])
var first = node.AttributeLists[0];
var prepended = first.WithAttributes(
SyntaxFactory.SeparatedList(new[] { newAttr }.Concat(first.Attributes)));
return node.WithAttributeLists(node.AttributeLists.Replace(first, prepended));
}
return (PropertyDeclarationSyntax)node.WithAttribute(attribute);
});
}

public static CompilationUnitSyntax AsInternal(
this CompilationUnitSyntax root,
string name,
Expand Down
17 changes: 13 additions & 4 deletions src/Sentry.Bindings.Cocoa/ApiDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@
[NullAllowed, Export("origin")]
string Origin { get; set; }

// @property (nonatomic, strong) NSDictionary<NSString *,id> * _Nullable data;
[NullAllowed, Export("data", ArgumentSemantic.Strong)]
// @property (copy, nonatomic) NSDictionary<NSString *,id> * _Nullable data;
[NullAllowed, Export("data", ArgumentSemantic.Copy)]
NSDictionary<NSString, NSObject> Data { get; set; }

// -(instancetype _Nonnull)initWithLevel:(SentryLevel)level category:(NSString * _Nonnull)category;
Expand Down Expand Up @@ -1746,10 +1746,14 @@
[NullAllowed, Export("beforeCaptureViewHierarchy", ArgumentSemantic.Copy)]
SentryBeforeCaptureScreenshotCallback BeforeCaptureViewHierarchy { get; set; }

// @property (copy, nonatomic) SentryOnCrashedLastRunCallback _Nullable onCrashedLastRun;
// @property (copy, nonatomic) SWIFT_DEPRECATED_MSG("Use onLastRunStatusDetermined instead, which is called regardless of whether the app crashed.") SentryOnCrashedLastRunCallback onCrashedLastRun __attribute__((deprecated("Use onLastRunStatusDetermined instead, which is called regardless of whether the app crashed.")));
[NullAllowed, Export("onCrashedLastRun", ArgumentSemantic.Copy)]
SentryOnCrashedLastRunCallback OnCrashedLastRun { get; set; }

// @property (copy, nonatomic) void (^ _Nullable)(enum SentryLastRunStatus, SentryEvent * _Nullable) onLastRunStatusDetermined;
[NullAllowed, Export("onLastRunStatusDetermined", ArgumentSemantic.Copy)]
Action<SentryLastRunStatus, SentryEvent?> OnLastRunStatusDetermined { get; set; }

Check warning on line 1755 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1755 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1755 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1755 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1755 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1755 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1755 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1755 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1755 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 1755 in src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

View workflow job for this annotation

GitHub Actions / ios-tests

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

// @property (nonatomic, strong) NSNumber * _Nullable sampleRate;
[NullAllowed, Export("sampleRate", ArgumentSemantic.Strong)]
NSNumber SampleRate { get; set; }
Expand Down Expand Up @@ -2736,11 +2740,16 @@
[Export("configureScope:")]
void ConfigureScope(Action<SentryScope> callback);

// @property (readonly, nonatomic, class) BOOL crashedLastRun;
// @property (readonly, nonatomic, class) BOOL crashedLastRun __attribute__((deprecated("Use lastRunStatus instead, which distinguishes between 'did not crash' and 'unknown'.")));
[Static]
[Export("crashedLastRun")]
bool CrashedLastRun { get; }

// @property (readonly, nonatomic, class) enum SentryLastRunStatus lastRunStatus;
[Static]
[Export("lastRunStatus")]
SentryLastRunStatus LastRunStatus { get; }

// @property (readonly, nonatomic, class) BOOL detectedStartUpCrash;
[Static]
[Export("detectedStartUpCrash")]
Expand Down
8 changes: 8 additions & 0 deletions src/Sentry.Bindings.Cocoa/StructsAndEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ internal enum SentryHttpStatusCode : long
InternalServerError = 500
}

[Native]
internal enum SentryLastRunStatus : long
{
Unknown = 0,
DidNotCrash = 1,
DidCrash = 2
}

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