Skip to content
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

Bug: Infinite recursion #1892

Closed
nielsenko opened this issue Aug 7, 2019 · 1 comment · Fixed by #1893
Closed

Bug: Infinite recursion #1892

nielsenko opened this issue Aug 7, 2019 · 1 comment · Fixed by #1893
Assignees

Comments

@nielsenko
Copy link
Contributor

nielsenko commented Aug 7, 2019

RealmResult<T>.IndexOf(object o) recurses infinitely.

Test case:

public class Dummy : RealmObject
{
    public IList<Dummy> Friends { get; }
}

[Test]
public void IndexOfTest()
{
    using (var realm = OpenRealm())
    {
        var f = new Dummy();
        var d = new Dummy { Friends = { f } };

         var realmList = d.Friends;
         Assert.That(realmList.IndexOf(f), Is.Zero);

         var realmResult = realm.All<Dummy>() as RealmCollectionBase<Dummy>;
         // Assert.That(realmResult.IndexOf(f), Is.Not.Negative); // this causes infinite recursion!
    }
}

This happens because RealmResult<T> implements IndexOf(object o) as:

public override int IndexOf(object value) => IndexOf((T)value);

but doesn't implement a IndexOf(T item), unlike RealmList<T> which also derive from RealmCollectionBase<T>.

@nielsenko
Copy link
Contributor Author

I can confirm this is fixed with 4.2.0

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants