Skip to content

Commit 7870f84

Browse files
committed
Minimize Cocoa bindings
1 parent 2b52d96 commit 7870f84

File tree

2 files changed

+18
-285
lines changed

2 files changed

+18
-285
lines changed

scripts/post-process-cocoa-bindings.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,29 @@
1212
var code = File.ReadAllText(args[0]);
1313
var tree = CSharpSyntaxTree.ParseText(code);
1414
var root = tree.GetCompilationUnitRoot();
15-
var filtered = root.RemoveNodes(
15+
root = root?.RemoveNodes(
16+
root.DescendantNodes()
17+
.OfType<MethodDeclarationSyntax>()
18+
.Where(c => Blacklist.Methods.Contains(c.Identifier.Text)),
19+
SyntaxRemoveOptions.KeepNoTrivia
20+
);
21+
root = root?.RemoveNodes(
1622
root.DescendantNodes()
1723
.OfType<InterfaceDeclarationSyntax>()
1824
.Where(c => !Whitelist.Interfaces.Contains(c.Identifier.Text)),
1925
SyntaxRemoveOptions.KeepNoTrivia
2026
);
21-
File.WriteAllText(args[0], filtered?.ToFullString());
27+
File.WriteAllText(args[0], root?.ToFullString());
28+
29+
internal static class Blacklist
30+
{
31+
public static readonly HashSet<string> Methods = new()
32+
{
33+
"StoreEnvelope",
34+
"CaptureEnvelope",
35+
"EnvelopeWithData",
36+
};
37+
}
2238

2339
internal static class Whitelist
2440
{
@@ -30,16 +46,9 @@ internal static class Whitelist
3046
"SentryBaggage",
3147
"SentryBreadcrumb",
3248
"SentryClient",
33-
"SentryClientReport",
34-
"SentryCurrentDateProvider",
3549
"SentryDebugImageProvider",
3650
"SentryDebugMeta",
37-
"SentryDiscardedEvent",
3851
"SentryDsn",
39-
"SentryEnvelope",
40-
"SentryEnvelopeHeader",
41-
"SentryEnvelopeItem",
42-
"SentryEnvelopeItemHeader",
4352
"SentryEvent",
4453
"SentryException",
4554
"SentryFeedback",
@@ -68,7 +77,6 @@ internal static class Whitelist
6877
"SentryReplayBreadcrumbConverter",
6978
"SentryReplayEvent",
7079
"SentryReplayOptions",
71-
"SentryReplayRecording",
7280
"SentryRequest",
7381
"SentryRRWebEvent",
7482
"SentrySamplingContext",
@@ -93,7 +101,6 @@ internal static class Whitelist
93101
"SentryUserFeedbackFormConfiguration",
94102
"SentryUserFeedbackThemeConfiguration",
95103
"SentryUserFeedbackWidgetConfiguration",
96-
"SentryVideoInfo",
97104
"SentryViewScreenshotOptions",
98105
"SentryViewScreenshotProvider",
99106
};

src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

Lines changed: 0 additions & 274 deletions
Original file line numberDiff line numberDiff line change
@@ -399,54 +399,6 @@ interface SentryDsn
399399
NSUrl EnvelopeEndpoint { get; }
400400
}
401401

402-
// @interface SentryEnvelopeItemHeader : NSObject <SentrySerializable>
403-
[BaseType (typeof(NSObject))]
404-
[DisableDefaultCtor]
405-
[Internal]
406-
interface SentryEnvelopeItemHeader : SentrySerializable
407-
{
408-
// -(instancetype _Nonnull)initWithType:(NSString * _Nonnull)type length:(NSUInteger)length __attribute__((objc_designated_initializer));
409-
[Export ("initWithType:length:")]
410-
[DesignatedInitializer]
411-
NativeHandle Constructor (string type, nuint length);
412-
413-
// -(instancetype _Nonnull)initWithType:(NSString * _Nonnull)type length:(NSUInteger)length contentType:(NSString * _Nonnull)contentType;
414-
[Export ("initWithType:length:contentType:")]
415-
NativeHandle Constructor (string type, nuint length, string contentType);
416-
417-
// -(instancetype _Nonnull)initWithType:(NSString * _Nonnull)type length:(NSUInteger)length filenname:(NSString * _Nonnull)filename contentType:(NSString * _Nonnull)contentType;
418-
[Export ("initWithType:length:filenname:contentType:")]
419-
NativeHandle Constructor (string type, nuint length, string filename, string contentType);
420-
421-
// -(instancetype _Nonnull)initWithType:(NSString * _Nonnull)type length:(NSUInteger)length contentType:(NSString * _Nullable)contentType itemCount:(NSNumber * _Nonnull)itemCount;
422-
[Export ("initWithType:length:contentType:itemCount:")]
423-
NativeHandle Constructor (string type, nuint length, [NullAllowed] string contentType, NSNumber itemCount);
424-
425-
// @property (readonly, copy, nonatomic) NSString * _Nonnull type;
426-
[Export ("type")]
427-
string Type { get; }
428-
429-
// @property (readonly, nonatomic) NSUInteger length;
430-
[Export ("length")]
431-
nuint Length { get; }
432-
433-
// @property (readonly, copy, nonatomic) NSString * _Nullable filename;
434-
[NullAllowed, Export ("filename")]
435-
string Filename { get; }
436-
437-
// @property (readonly, copy, nonatomic) NSString * _Nullable contentType;
438-
[NullAllowed, Export ("contentType")]
439-
string ContentType { get; }
440-
441-
// @property (readonly, copy, nonatomic) NSNumber * _Nullable itemCount;
442-
[NullAllowed, Export ("itemCount", ArgumentSemantic.Copy)]
443-
NSNumber ItemCount { get; }
444-
445-
// @property (copy, nonatomic) NSString * _Nullable platform;
446-
[NullAllowed, Export ("platform")]
447-
string Platform { get; set; }
448-
}
449-
450402
partial interface Constants
451403
{
452404
// extern NSString *const _Nonnull SentryErrorDomain __attribute__((visibility("default")));
@@ -2201,187 +2153,6 @@ interface SentryUser : SentrySerializable
22012153
nuint Hash { get; }
22022154
}
22032155

2204-
// @interface SentryClientReport : NSObject <SentrySerializable>
2205-
[BaseType (typeof(NSObject), Name = "_TtC6Sentry18SentryClientReport")]
2206-
[DisableDefaultCtor]
2207-
[Internal]
2208-
interface SentryClientReport : SentrySerializable
2209-
{
2210-
// -(instancetype _Nonnull)initWithDiscardedEvents:(NSArray<SentryDiscardedEvent *> * _Nonnull)discardedEvents dateProvider:(id<SentryCurrentDateProvider> _Nonnull)dateProvider __attribute__((objc_designated_initializer));
2211-
[Export ("initWithDiscardedEvents:dateProvider:")]
2212-
[DesignatedInitializer]
2213-
NativeHandle Constructor (SentryDiscardedEvent[] discardedEvents, SentryCurrentDateProvider dateProvider);
2214-
2215-
// -(NSDictionary<NSString *,id> * _Nonnull)serialize __attribute__((warn_unused_result("")));
2216-
[Export ("serialize")]
2217-
NSDictionary<NSString, NSObject> Serialize();
2218-
}
2219-
2220-
// @protocol SentryCurrentDateProvider
2221-
[Protocol (Name = "_TtP6Sentry25SentryCurrentDateProvider_")]
2222-
[Model]
2223-
[Internal]
2224-
[BaseType (typeof(NSObject))]
2225-
interface SentryCurrentDateProvider
2226-
{
2227-
// @required -(NSDate * _Nonnull)date __attribute__((warn_unused_result("")));
2228-
[Abstract]
2229-
[Export ("date")]
2230-
NSDate Date();
2231-
2232-
// @required -(NSInteger)timezoneOffset __attribute__((warn_unused_result("")));
2233-
[Abstract]
2234-
[Export ("timezoneOffset")]
2235-
nint TimezoneOffset();
2236-
2237-
// @required -(uint64_t)systemTime __attribute__((warn_unused_result("")));
2238-
[Abstract]
2239-
[Export ("systemTime")]
2240-
ulong SystemTime();
2241-
2242-
// @required -(NSTimeInterval)systemUptime __attribute__((warn_unused_result("")));
2243-
[Abstract]
2244-
[Export ("systemUptime")]
2245-
double SystemUptime();
2246-
}
2247-
2248-
// @interface SentryDiscardedEvent : NSObject <SentrySerializable>
2249-
[BaseType (typeof(NSObject), Name = "_TtC6Sentry20SentryDiscardedEvent")]
2250-
[DisableDefaultCtor]
2251-
[Internal]
2252-
interface SentryDiscardedEvent : SentrySerializable
2253-
{
2254-
// @property (readonly, nonatomic) NSUInteger quantity;
2255-
[Export ("quantity")]
2256-
nuint Quantity { get; }
2257-
2258-
// -(instancetype _Nonnull)initWithReason:(NSString * _Nonnull)reason category:(NSString * _Nonnull)category quantity:(NSUInteger)quantity __attribute__((objc_designated_initializer));
2259-
[Export ("initWithReason:category:quantity:")]
2260-
[DesignatedInitializer]
2261-
NativeHandle Constructor (string reason, string category, nuint quantity);
2262-
2263-
// -(NSDictionary<NSString *,id> * _Nonnull)serialize __attribute__((warn_unused_result("")));
2264-
[Export ("serialize")]
2265-
NSDictionary<NSString, NSObject> Serialize();
2266-
}
2267-
2268-
// @interface SentryEnvelope : NSObject
2269-
[BaseType (typeof(NSObject), Name = "_TtC6Sentry14SentryEnvelope")]
2270-
[DisableDefaultCtor]
2271-
[Internal]
2272-
interface SentryEnvelope
2273-
{
2274-
// -(instancetype _Nonnull)initWithId:(SentryId * _Nullable)id singleItem:(SentryEnvelopeItem * _Nonnull)item __attribute__((deprecated("This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")));
2275-
[Export ("initWithId:singleItem:")]
2276-
NativeHandle Constructor ([NullAllowed] SentryId id, SentryEnvelopeItem item);
2277-
2278-
// -(instancetype _Nonnull)initWithHeader:(SentryEnvelopeHeader * _Nonnull)header singleItem:(SentryEnvelopeItem * _Nonnull)item;
2279-
[Export ("initWithHeader:singleItem:")]
2280-
NativeHandle Constructor (SentryEnvelopeHeader header, SentryEnvelopeItem item);
2281-
2282-
// -(instancetype _Nonnull)initWithId:(SentryId * _Nullable)id items:(NSArray<SentryEnvelopeItem *> * _Nonnull)items __attribute__((deprecated("This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")));
2283-
[Export ("initWithId:items:")]
2284-
NativeHandle Constructor ([NullAllowed] SentryId id, SentryEnvelopeItem[] items);
2285-
2286-
// -(instancetype _Nonnull)initWithHeader:(SentryEnvelopeHeader * _Nonnull)header items:(NSArray<SentryEnvelopeItem *> * _Nonnull)items __attribute__((objc_designated_initializer));
2287-
[Export ("initWithHeader:items:")]
2288-
[DesignatedInitializer]
2289-
NativeHandle Constructor (SentryEnvelopeHeader header, SentryEnvelopeItem[] items);
2290-
2291-
// @property (readonly, nonatomic, strong) SentryEnvelopeHeader * _Nonnull header;
2292-
[Export ("header", ArgumentSemantic.Strong)]
2293-
SentryEnvelopeHeader Header { get; }
2294-
2295-
// @property (readonly, copy, nonatomic) NSArray<SentryEnvelopeItem *> * _Nonnull items;
2296-
[Export ("items", ArgumentSemantic.Copy)]
2297-
SentryEnvelopeItem[] Items { get; }
2298-
}
2299-
2300-
// @interface SentryEnvelopeHeader : NSObject
2301-
[BaseType (typeof(NSObject), Name = "_TtC6Sentry20SentryEnvelopeHeader")]
2302-
[DisableDefaultCtor]
2303-
[Internal]
2304-
interface SentryEnvelopeHeader
2305-
{
2306-
// -(instancetype _Nonnull)initWithId:(SentryId * _Nullable)eventId __attribute__((deprecated("This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")));
2307-
[Export ("initWithId:")]
2308-
NativeHandle Constructor ([NullAllowed] SentryId eventId);
2309-
2310-
// -(instancetype _Nonnull)initWithId:(SentryId * _Nullable)eventId traceContext:(SentryTraceContext * _Nullable)traceContext __attribute__((deprecated("This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")));
2311-
[Export ("initWithId:traceContext:")]
2312-
NativeHandle Constructor ([NullAllowed] SentryId eventId, [NullAllowed] SentryTraceContext traceContext);
2313-
2314-
// -(instancetype _Nonnull)initWithId:(SentryId * _Nullable)eventId sdkInfo:(SentrySdkInfo * _Nullable)sdkInfo traceContext:(SentryTraceContext * _Nullable)traceContext __attribute__((objc_designated_initializer));
2315-
[Export ("initWithId:sdkInfo:traceContext:")]
2316-
[DesignatedInitializer]
2317-
NativeHandle Constructor ([NullAllowed] SentryId eventId, [NullAllowed] SentrySdkInfo sdkInfo, [NullAllowed] SentryTraceContext traceContext);
2318-
2319-
// +(instancetype _Nonnull)empty __attribute__((warn_unused_result(""))) __attribute__((deprecated("This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")));
2320-
[Static]
2321-
[Export ("empty")]
2322-
SentryEnvelopeHeader Empty ();
2323-
2324-
// @property (nonatomic, strong) SentryId * _Nullable eventId;
2325-
[NullAllowed, Export ("eventId", ArgumentSemantic.Strong)]
2326-
SentryId EventId { get; set; }
2327-
2328-
// @property (nonatomic, strong) SentrySdkInfo * _Nullable sdkInfo;
2329-
[NullAllowed, Export ("sdkInfo", ArgumentSemantic.Strong)]
2330-
SentrySdkInfo SdkInfo { get; set; }
2331-
2332-
// @property (nonatomic, strong) SentryTraceContext * _Nullable traceContext;
2333-
[NullAllowed, Export ("traceContext", ArgumentSemantic.Strong)]
2334-
SentryTraceContext TraceContext { get; set; }
2335-
2336-
// @property (copy, nonatomic) NSDate * _Nullable sentAt;
2337-
[NullAllowed, Export ("sentAt", ArgumentSemantic.Copy)]
2338-
NSDate SentAt { get; set; }
2339-
}
2340-
2341-
// @interface SentryEnvelopeItem : NSObject
2342-
[BaseType (typeof(NSObject), Name = "_TtC6Sentry18SentryEnvelopeItem")]
2343-
[DisableDefaultCtor]
2344-
[Internal]
2345-
interface SentryEnvelopeItem
2346-
{
2347-
// @property (readonly, nonatomic, strong) SentryEnvelopeItemHeader * _Nonnull header;
2348-
[Export ("header", ArgumentSemantic.Strong)]
2349-
SentryEnvelopeItemHeader Header { get; }
2350-
2351-
// @property (readonly, copy, nonatomic) NSData * _Nullable data;
2352-
[NullAllowed, Export ("data", ArgumentSemantic.Copy)]
2353-
NSData Data { get; }
2354-
2355-
// -(instancetype _Nonnull)initWithHeader:(SentryEnvelopeItemHeader * _Nonnull)header data:(NSData * _Nullable)data __attribute__((objc_designated_initializer));
2356-
[Export ("initWithHeader:data:")]
2357-
[DesignatedInitializer]
2358-
NativeHandle Constructor (SentryEnvelopeItemHeader header, [NullAllowed] NSData data);
2359-
2360-
// -(instancetype _Nonnull)initWithEvent:(SentryEvent * _Nonnull)event;
2361-
[Export ("initWithEvent:")]
2362-
NativeHandle Constructor (SentryEvent @event);
2363-
2364-
// -(instancetype _Nonnull)initWithSession:(SentrySession * _Nonnull)session;
2365-
[Export ("initWithSession:")]
2366-
NativeHandle Constructor (SentrySession session);
2367-
2368-
// -(instancetype _Nonnull)initWithUserFeedback:(SentryUserFeedback * _Nonnull)userFeedback __attribute__((deprecated("Building the envelopes for the new SentryFeedback type is done directly in -[SentryClient captureFeedback:withScope:] so there will be no analog to this initializer for SentryFeedback at this time.")));
2369-
[Export ("initWithUserFeedback:")]
2370-
NativeHandle Constructor (SentryUserFeedback userFeedback);
2371-
2372-
// -(instancetype _Nullable)initWithAttachment:(SentryAttachment * _Nonnull)attachment maxAttachmentSize:(NSUInteger)maxAttachmentSize;
2373-
[Export ("initWithAttachment:maxAttachmentSize:")]
2374-
NativeHandle Constructor (SentryAttachment attachment, nuint maxAttachmentSize);
2375-
2376-
// -(instancetype _Nonnull)initWithClientReport:(SentryClientReport * _Nonnull)clientReport;
2377-
[Export ("initWithClientReport:")]
2378-
NativeHandle Constructor (SentryClientReport clientReport);
2379-
2380-
// -(instancetype _Nullable)initWithReplayEvent:(SentryReplayEvent * _Nonnull)replayEvent replayRecording:(SentryReplayRecording * _Nonnull)replayRecording video:(NSURL * _Nonnull)video;
2381-
[Export ("initWithReplayEvent:replayRecording:video:")]
2382-
NativeHandle Constructor (SentryReplayEvent replayEvent, SentryReplayRecording replayRecording, NSUrl video);
2383-
}
2384-
23852156
// @interface SentryFeedback : NSObject
23862157
[BaseType (typeof(NSObject), Name = "_TtC6Sentry14SentryFeedback")]
23872158
[DisableDefaultCtor]
@@ -2696,17 +2467,6 @@ interface SentryReplayOptions //: ISentryRedactOptions
26962467
NativeHandle Constructor (float sessionSampleRate, float onErrorSampleRate, bool maskAllText, bool maskAllImages, bool enableViewRendererV2, bool enableFastViewRendering);
26972468
}
26982469

2699-
// @interface SentryReplayRecording : NSObject
2700-
[BaseType (typeof(NSObject), Name = "_TtC6Sentry21SentryReplayRecording")]
2701-
[DisableDefaultCtor]
2702-
[Internal]
2703-
interface SentryReplayRecording
2704-
{
2705-
// -(instancetype _Nonnull)initWithSegmentId:(NSInteger)segmentId video:(SentryVideoInfo * _Nonnull)video extraEvents:(NSArray<id<SentryRRWebEvent>> * _Nonnull)extraEvents;
2706-
[Export ("initWithSegmentId:video:extraEvents:")]
2707-
NativeHandle Constructor (nint segmentId, SentryVideoInfo video, SentryRRWebEvent[] extraEvents);
2708-
}
2709-
27102470
// @interface SentrySDK : NSObject
27112471
[BaseType (typeof(NSObject), Name = "_TtC6Sentry9SentrySDK")]
27122472
[Internal]
@@ -3350,25 +3110,6 @@ interface SentryUserFeedbackWidgetConfiguration
33503110
UIOffset LayoutUIOffset { get; set; }
33513111
}
33523112

3353-
// @interface SentryVideoInfo : NSObject
3354-
[BaseType (typeof(NSObject), Name = "_TtC6Sentry15SentryVideoInfo")]
3355-
[DisableDefaultCtor]
3356-
[Internal]
3357-
interface SentryVideoInfo
3358-
{
3359-
// @property (readonly, copy, nonatomic) NSURL * _Nonnull path;
3360-
[Export ("path", ArgumentSemantic.Copy)]
3361-
NSUrl Path { get; }
3362-
3363-
// @property (readonly, copy, nonatomic) NSDate * _Nonnull start;
3364-
[Export ("start", ArgumentSemantic.Copy)]
3365-
NSDate Start { get; }
3366-
3367-
// @property (readonly, copy, nonatomic) NSDate * _Nonnull end;
3368-
[Export ("end", ArgumentSemantic.Copy)]
3369-
NSDate End { get; }
3370-
}
3371-
33723113
// @protocol SentryViewScreenshotProvider <NSObject>
33733114
[Protocol (Name = "_TtP6Sentry28SentryViewScreenshotProvider_")]
33743115
[BaseType (typeof(NSObject), Name = "_TtP6Sentry28SentryViewScreenshotProvider_")]
@@ -3492,21 +3233,6 @@ interface SentryScreenFrames
34923233
[Internal]
34933234
interface PrivateSentrySDKOnly
34943235
{
3495-
// +(void)storeEnvelope:(SentryEnvelope * _Nonnull)envelope;
3496-
[Static]
3497-
[Export ("storeEnvelope:")]
3498-
void StoreEnvelope (SentryEnvelope envelope);
3499-
3500-
// +(void)captureEnvelope:(SentryEnvelope * _Nonnull)envelope;
3501-
[Static]
3502-
[Export ("captureEnvelope:")]
3503-
void CaptureEnvelope (SentryEnvelope envelope);
3504-
3505-
// +(SentryEnvelope * _Nullable)envelopeWithData:(NSData * _Nonnull)data;
3506-
[Static]
3507-
[Export ("envelopeWithData:")]
3508-
[return: NullAllowed]
3509-
SentryEnvelope EnvelopeWithData (NSData data);
35103236

35113237
// +(NSArray<SentryDebugMeta *> * _Nonnull)getDebugImages;
35123238
[Static]

0 commit comments

Comments
 (0)