-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add keypath filtering for Property/CollectionChanged #3121
Conversation
|
41e1de8
to
0c846c4
Compare
...lm.SourceGenerator/Realms.SourceGenerator.RealmGenerator/TestNotificationObject_generated.cs
Show resolved
Hide resolved
a1ed80f
to
b51e8b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the tests make sense! Probably it'll be worth adding also collections of other types, in the same way you did for single link
@@ -181,12 +181,15 @@ public void SubscribeForNotifications(Action<string> notifyPropertyChangedDelega | |||
throw new RealmFrozenException("It is not possible to add a change listener to a frozen RealmObjectBase since it never changes."); | |||
} | |||
|
|||
PropertyType collectionFlag = PropertyType.Array | PropertyType.Dictionary | PropertyType.Set; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we also need to check backlinks? I'm not sure we get notifications for those in any case.
Also, it would make sense to calculate those indices only once, they are not going to change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backlinks are in a separate vector in the Object Store ObjectSchema
so even if they cause notifications they need to be handled separately. But we need to see if they raise notifications in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test to check this, and they don't in our case
@@ -181,12 +181,15 @@ public void SubscribeForNotifications(Action<string> notifyPropertyChangedDelega | |||
throw new RealmFrozenException("It is not possible to add a change listener to a frozen RealmObjectBase since it never changes."); | |||
} | |||
|
|||
PropertyType collectionFlag = PropertyType.Array | PropertyType.Dictionary | PropertyType.Set; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backlinks are in a separate vector in the Object Store ObjectSchema
so even if they cause notifications they need to be handled separately. But we need to see if they raise notifications in the first place.
…fication_callback
{ | ||
EnsureIsOpen(); | ||
|
||
var result = NativeMethods.add_notification_callback(this, managedObjectHandle, out var nativeException); | ||
var propertyIndicesLength = propertyIndices == null ? (IntPtr)0 : (IntPtr)propertyIndices.Length; | ||
var result = NativeMethods.add_notification_callback(this, managedObjectHandle, propertyIndices, propertyIndicesLength, out var nativeException); |
Check notice
Code scanning / CodeQL
Calls to unmanaged code
{ | ||
EnsureIsOpen(); | ||
|
||
var result = NativeMethods.add_notification_callback(this, managedObjectHandle, out var nativeException); | ||
var propertyIndicesLength = propertyIndices == null ? (IntPtr)0 : (IntPtr)propertyIndices.Length; | ||
var result = NativeMethods.add_notification_callback(this, managedObjectHandle, propertyIndices, propertyIndicesLength, out var nativeException); |
Check notice
Code scanning / CodeQL
Calls to unmanaged code
|
||
var result = NativeMethods.add_notification_callback(this, managedObjectHandle, out var nativeException); | ||
var propertyIndicesLength = propertyIndices == null ? (IntPtr)0 : (IntPtr)propertyIndices.Length; | ||
var result = NativeMethods.add_notification_callback(this, managedObjectHandle, propertyIndices, propertyIndicesLength, out var nativeException); |
Check notice
Code scanning / CodeQL
Calls to unmanaged code
{ | ||
EnsureIsOpen(); | ||
|
||
var result = NativeMethods.add_notification_callback(this, managedObjectHandle, out var nativeException); | ||
var propertyIndicesLength = propertyIndices == null ? (IntPtr)0 : (IntPtr)propertyIndices.Length; | ||
var result = NativeMethods.add_notification_callback(this, managedObjectHandle, propertyIndices, propertyIndicesLength, out var nativeException); |
Check notice
Code scanning / CodeQL
Calls to unmanaged code
{ | ||
EnsureIsOpen(); | ||
|
||
var result = NativeMethods.add_notification_callback(this, managedObjectHandle, out var nativeException); | ||
var propertyIndicesLength = propertyIndices == null ? (IntPtr)0 : (IntPtr)propertyIndices.Length; | ||
var result = NativeMethods.add_notification_callback(this, managedObjectHandle, propertyIndices, propertyIndicesLength, out var nativeException); |
Check notice
Code scanning / CodeQL
Calls to unmanaged code
@@ -63,7 +64,7 @@ | |||
public static extern void destroy(IntPtr listInternalHandle); | |||
|
|||
[DllImport(InteropConfig.DLL_NAME, EntryPoint = "list_add_notification_callback", CallingConvention = CallingConvention.Cdecl)] | |||
public static extern IntPtr add_notification_callback(ListHandle listHandle, IntPtr managedListHandle, out NativeException ex); | |||
public static extern IntPtr add_notification_callback(ListHandle listHandle, IntPtr managedListHandle, [MarshalAs(UnmanagedType.LPArray), In] IntPtr[] propjerty_indices, IntPtr property_count, out NativeException ex); |
Check notice
Code scanning / CodeQL
Unmanaged code
@@ -43,7 +44,7 @@ | |||
public static extern void clear(ResultsHandle results, SharedRealmHandle realmHandle, out NativeException ex); | |||
|
|||
[DllImport(InteropConfig.DLL_NAME, EntryPoint = "results_add_notification_callback", CallingConvention = CallingConvention.Cdecl)] | |||
public static extern IntPtr add_notification_callback(ResultsHandle results, IntPtr managedResultsHandle, out NativeException ex); | |||
public static extern IntPtr add_notification_callback(ResultsHandle results, IntPtr managedResultsHandle, [MarshalAs(UnmanagedType.LPArray), In] IntPtr[] propjerty_indices, IntPtr property_count, out NativeException ex); |
Check notice
Code scanning / CodeQL
Unmanaged code
@@ -36,7 +37,7 @@ | |||
public static extern void destroy(IntPtr handle); | |||
|
|||
[DllImport(InteropConfig.DLL_NAME, EntryPoint = "realm_set_add_notification_callback", CallingConvention = CallingConvention.Cdecl)] | |||
public static extern IntPtr add_notification_callback(SetHandle handle, IntPtr managedSetHandle, out NativeException ex); | |||
public static extern IntPtr add_notification_callback(SetHandle handle, IntPtr managedSetHandle, [MarshalAs(UnmanagedType.LPArray), In] IntPtr[] propjerty_indices, IntPtr property_count, out NativeException ex); |
Check notice
Code scanning / CodeQL
Unmanaged code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small comments. I'd also like to see the PR updated with the Core submodule pointing to the Core branch so I can see the related wrappers changes in full as well.
Partially Fixes #3112. initially we will internally filter the notifications in the following manner:
This PR needs to wait until these changes are merged to core