jamesmontemagno / Xamarin.Plugins

Cross-platform Native API Access from Shared Code!
MIT License
1.3k stars 380 forks source link

Add better null handling to contact loading. #346

Closed josemh closed 7 years ago

josemh commented 7 years ago

Which Plugin does this impact: Contact - https://github.com/jamesmontemagno/Xamarin.Plugins/tree/master/Contacts

Bug

Calling CrossContacts.Current.Contacts.ToList() should return a list of all contacts.

Actual Behavior

I get the following error: Java.Lang.IllegalArgumentException: the bind value at index 255 is null

It seems there is a contact on this particular phone with an null CONTACT_ID. Perhaps this is due to data corruption.

Steps to reproduce the Behavior

In the following method of the ContactsHelper class (line 63):

    internal static IEnumerable<Contact> GetContacts(ICursor cursor, bool rawContacts, ContentResolver content, Resources resources, int batchSize)

The id should be checked for null. So line 88 should be change from:

    if (uniques.Contains(id))

To:

    if (uniques.Contains(id) || id == null)

Feature Request:

Add better null handling to contact loading.

jamesmontemagno commented 7 years ago

will be in https://github.com/jamesmontemagno/ContactsPlugin Updated the code to reflect this.