Skip to content

Commit 3338a5a

Browse files
[codex] Fix Firebase binding nullability annotations and add E2E validation (#111)
* Fix Firebase nullability annotations and add E2E validation * Use repo-relative links in Firebase E2E README * Include remaining Firebase nullability updates
1 parent 8540f98 commit 3338a5a

24 files changed

Lines changed: 1026 additions & 21 deletions

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ bin
33
obj
44
output
55
tools
6+
!tools/
7+
tools/*
8+
!tools/e2e/
9+
tools/e2e/*
10+
!tools/e2e/run-firebase-foundation.sh
611
tmp-nugets
712
*.userprefs
813
*.DS_Store
@@ -15,4 +20,5 @@ _._
1520
externals
1621
artifacts
1722
*.user
18-
GoogleService-Info.plist
23+
GoogleService-Info.plist
24+
!tests/E2E/Firebase.Foundation/FirebaseFoundationE2E/GoogleService-Info.plist

source/Firebase/Analytics/ApiDefinition.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ interface Analytics
4242

4343
// + (nullable NSString *)appInstanceID;
4444
[Static]
45+
[NullAllowed]
4546
[Export ("appInstanceID")]
4647
string AppInstanceId { get; }
4748

source/Firebase/AppCheck/ApiDefinition.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Firebase.AppCheck {
77
// typedef void (^)(FIRAppCheckToken *_Nullable token, NSError *_Nullable error)
8-
delegate void TokenCompletionHandler (AppCheckToken token, NSError error);
8+
delegate void TokenCompletionHandler ([NullAllowed] AppCheckToken token, [NullAllowed] NSError error);
99

1010
interface IAppCheckProviderFactory { }
1111

@@ -97,6 +97,7 @@ interface AppCheckToken {
9797
[BaseType (typeof (NSObject), Name = "FIRAppCheckDebugProvider")]
9898
interface AppCheckDebugProvider : IAppCheckProvider {
9999
// -(instancetype _Nullable)initWithApp:(FIRApp * _Nonnull)app;
100+
[return: NullAllowed]
100101
[Export ("initWithApp:")]
101102
NativeHandle Constructor (App app);
102103

@@ -120,6 +121,7 @@ interface AppCheckDebugProviderFactory : AppCheckProviderFactory {
120121
[BaseType (typeof (NSObject), Name = "FIRDeviceCheckProvider")]
121122
interface DeviceCheckProvider : AppCheckProvider {
122123
// -(instancetype _Nullable)initWithApp:(FIRApp * _Nonnull)app;
124+
[return: NullAllowed]
123125
[Export ("initWithApp:")]
124126
NativeHandle Constructor (App app);
125127
}
@@ -130,6 +132,7 @@ interface DeviceCheckProvider : AppCheckProvider {
130132
[BaseType (typeof (NSObject), Name = "FIRAppAttestProvider")]
131133
interface AppAttestProvider : AppCheckProvider {
132134
// -(instancetype _Nullable)initWithApp:(FIRApp * _Nonnull)app;
135+
[return: NullAllowed]
133136
[Export ("initWithApp:")]
134137
NativeHandle Constructor (App app);
135138
}

source/Firebase/CloudFirestore/ApiDefinition.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ interface CollectionReference
4545

4646
// -(FIRDocumentReference * _Nonnull)addDocumentWithData:(NSDictionary<NSString *,id> * _Nonnull)data completion:(void (^ _Nullable)(NSError * _Nullable))completion;
4747
[Export ("addDocumentWithData:completion:")]
48-
DocumentReference AddDocument (NSDictionary<NSString, NSObject> nsData, AddDocumentCompletionHandler completion);
48+
DocumentReference AddDocument (NSDictionary<NSString, NSObject> nsData, [NullAllowed] AddDocumentCompletionHandler completion);
4949

5050
[Wrap ("AddDocument (data == null ? null : NSDictionary<NSString, NSObject>.FromObjectsAndKeys (System.Linq.Enumerable.ToArray (data.Values), System.Linq.Enumerable.ToArray (data.Keys), data.Keys.Count), completion)")]
51-
DocumentReference AddDocument (Dictionary<object, object> data, AddDocumentCompletionHandler completion);
51+
DocumentReference AddDocument (Dictionary<object, object> data, [NullAllowed] AddDocumentCompletionHandler completion);
5252
}
5353

5454
// @interface FIRDocumentChange : NSObject
@@ -247,6 +247,7 @@ interface DocumentSnapshot
247247
SnapshotMetadata Metadata { get; }
248248

249249
// -(NSDictionary<NSString *,id> * _Nonnull)data;
250+
[NullAllowed]
250251
[Export ("data")]
251252
NSDictionary<NSString, NSObject> Data { get; }
252253

source/Firebase/CloudFunctions/ApiDefinition.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ interface CloudFunctions
4848
HttpsCallable HttpsCallable(string name);
4949

5050
// @property(nonatomic, readonly, nullable) NSString *emulatorOrigin;
51+
[NullAllowed]
5152
[Export("emulatorOrigin")]
5253
string EmulatorOrigin { get; }
5354

source/Firebase/CloudMessaging/ApiDefinition.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ interface IMessagingDelegate
3737
[BaseType (typeof (NSObject), Name = "FIRMessagingDelegate")]
3838
interface MessagingDelegate
3939
{
40-
// @optional -(void)messaging:(FIRMessaging * _Nonnull)messaging didReceiveRegistrationToken:(NSString * _Nonnull)fcmToken;
40+
// @optional -(void)messaging:(FIRMessaging * _Nonnull)messaging didReceiveRegistrationToken:(NSString * _Nullable)fcmToken;
4141
[Export ("messaging:didReceiveRegistrationToken:")]
42-
void DidReceiveRegistrationToken (Messaging messaging, string fcmToken);
42+
void DidReceiveRegistrationToken (Messaging messaging, [NullAllowed] string fcmToken);
4343
}
4444

4545
// @interface FIRMessaging : NSObject
@@ -108,7 +108,7 @@ interface Messaging
108108
// -(void)subscribeToTopic:(NSString * _Nonnull)topic completion:(nullable FIRMessagingTopicOperationCompletion)completion;
109109
[Async]
110110
[Export ("subscribeToTopic:completion:")]
111-
void Subscribe (string topic, MessagingTopicOperationCompletionHandler completion);
111+
void Subscribe (string topic, [NullAllowed] MessagingTopicOperationCompletionHandler completion);
112112

113113
// -(void)unsubscribeFromTopic:(NSString * _Nonnull)topic;
114114
[Export ("unsubscribeFromTopic:")]
@@ -117,7 +117,7 @@ interface Messaging
117117
//-(void)unsubscribeFromTopic:(NSString * _Nonnull)topic completion:(nullable FIRMessagingTopicOperationCompletion)completion;
118118
[Async]
119119
[Export ("unsubscribeFromTopic:completion:")]
120-
void Unsubscribe (string topic, MessagingTopicOperationCompletionHandler completion);
120+
void Unsubscribe (string topic, [NullAllowed] MessagingTopicOperationCompletionHandler completion);
121121

122122
// -(FIRMessagingMessageInfo * _Nonnull)appDidReceiveMessage:(NSDictionary * _Nonnull)message;
123123
[Export ("appDidReceiveMessage:")]

source/Firebase/Core/ApiDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface App : INativeObject
3232

3333
// +(FIRApp * _Nullable)defaultApp;
3434
[Static]
35+
[NullAllowed]
3536
[Export ("defaultApp")]
3637
App DefaultInstance { get; }
3738

@@ -96,7 +97,6 @@ interface Options : INSCopying
9697
string ApiKey { get; set; }
9798

9899
// @property(nonatomic, copy) NSString *bundleID;
99-
[NullAllowed]
100100
[Export ("bundleID")]
101101
string BundleId { get; set; }
102102

source/Firebase/Crashlytics/ApiDefinition.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ interface Crashlytics
2323
[Export ("log:")]
2424
void Log (string message);
2525

26-
// -(void)setCustomValue:(id _Nonnull)value forKey:(NSString * _Nonnull)key;
26+
// -(void)setCustomValue:(id _Nullable)value forKey:(NSString * _Nonnull)key;
2727
[Export ("setCustomValue:forKey:")]
28-
void SetCustomValue (NSObject value, string key);
28+
void SetCustomValue ([NullAllowed] NSObject value, string key);
2929

3030
// -(void)setCustomKeysAndValues:(NSDictionary * _Nonnull)keysAndValues;
3131
[Export ("setCustomKeysAndValues:")]
3232
void SetCustomKeysAndValues (NSDictionary<NSString, NSObject> keysAndValues);
3333

34-
// -(void)setUserID:(NSString * _Nonnull)userID;
34+
// -(void)setUserID:(NSString * _Nullable)userID;
3535
[Export ("setUserID:")]
36-
void SetUserId (string userId);
36+
void SetUserId ([NullAllowed] string userId);
3737

3838
// -(void)recordError:(NSError * _Nonnull)error __attribute__((swift_name("record(error:)")));
3939
[Export ("recordError:")]
@@ -131,16 +131,16 @@ interface CrashlyticsReport {
131131
[Export ("log:")]
132132
void Log (string msg);
133133

134-
// -(void)setCustomValue:(id _Nonnull)value forKey:(NSString * _Nonnull)key;
134+
// -(void)setCustomValue:(id _Nullable)value forKey:(NSString * _Nonnull)key;
135135
[Export ("setCustomValue:forKey:")]
136-
void SetCustomValue (NSObject value, string key);
136+
void SetCustomValue ([NullAllowed] NSObject value, string key);
137137

138138
// -(void)setCustomKeysAndValues:(NSDictionary * _Nonnull)keysAndValues;
139139
[Export ("setCustomKeysAndValues:")]
140140
void SetCustomKeysAndValues (NSDictionary<NSString, NSObject> keysAndValues);
141141

142-
// -(void)setUserID:(NSString * _Nonnull)userID;
142+
// -(void)setUserID:(NSString * _Nullable)userID;
143143
[Export ("setUserID:")]
144-
void SetUserID (string userID);
144+
void SetUserID ([NullAllowed] string userID);
145145
}
146146
}

source/Firebase/Database/ApiDefinition.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ interface DatabaseReference
463463

464464
// -(void)runTransactionBlock:(FIRTransactionResult * _Nonnull (^ _Nonnull)(FIRMutableData * _Nonnull))block andCompletionBlock:(void (^ _Nullable)(NSError * _Nullable, BOOL, FIRDataSnapshot * _Nullable))completionBlock withLocalEvents:(BOOL)localEvents;
465465
[Export ("runTransactionBlock:andCompletionBlock:withLocalEvents:")]
466-
void RunTransaction (DatabaseReferenceTransactionHandler transactionHandler, DatabaseReferenceTransactionCompletionHandler completionBlock, bool localEvents);
466+
void RunTransaction (DatabaseReferenceTransactionHandler transactionHandler, [NullAllowed] DatabaseReferenceTransactionCompletionHandler completionBlock, bool localEvents);
467467

468468
// -(NSString * _Nonnull)description;
469469
[New]
@@ -480,6 +480,7 @@ interface DatabaseReference
480480
DatabaseReference Root { get; }
481481

482482
// @property (readonly, nonatomic, strong) NSString * _Nonnull key;
483+
[NullAllowed]
483484
[Export ("key", ArgumentSemantic.Strong)]
484485
string Key { get; }
485486

source/Firebase/PerformanceMonitoring/ApiDefinition.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace Firebase.PerformanceMonitoring
1313
interface HttpMetric : PerformanceAttributable
1414
{
1515
// -(instancetype _Nullable)initWithURL:(NSURL * _Nonnull)URL HTTPMethod:(FIRHTTPMethod)httpMethod;
16+
[return: NullAllowed]
1617
[Export ("initWithURL:HTTPMethod:")]
1718
NativeHandle Constructor (NSUrl url, HttpMethod httpMethod);
1819

0 commit comments

Comments
 (0)