Skip to content

Exception not thrown when pass wrong index values in INotifiyCollectionChanged in Android #26941

@nivetha-nagalingam

Description

@nivetha-nagalingam

Description

When performing multi-item collection operations (AddRange) in a MAUI application using an ObservableCollection, there is inconsistent behavior on Android platforms.
On the other platforms, attempting to add multiple items triggers the expected ArgumentException and updates the UI label to "Success". However, on Android, the operation proceeds without throwing the exception, adds the items to the collection, and fails to update the UI label.
Reference Issue: xamarin/Xamarin.Forms#948
Note: While fixing this issue enable the following UITest in HostApp: Bugzilla56771

Screen.Recording.2025-01-02.at.10.56.58.PM.mov

Steps to Reproduce

  1. Run the below application.
  2. Bugzilla56771Exception.cs.zip
  3. Click the "Add 2" button.
  4. Observe that the label does not change to "Success" and items are added
    Expected Behavior
    1. When clicking the "Add 2" button:
    2. An ArgumentException should be thrown
    3. The label text should be updated to "Success"
    Actual Behavior on Android
    1. When clicking the "Add 2" button:
    2. No ArgumentException is thrown
    3. The label text remains unchanged
    4. The items are added to the collection

Link to public reproduction project repository

No response

Version with bug

9.0.21 SR2.1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions