Search Unity

Bug in generated Unity.Collections.FixedListXXX family's Remove function

Discussion in 'Entity Component System' started by R2-RT, Jan 23, 2020.

  1. R2-RT

    R2-RT

    Joined:
    May 8, 2019
    Posts:
    38
    I found out that implementation of Remove function has a bug that makes it delete multiple items (exactly index + 1) not single one.
    Code (CSharp):
    1. public bool Remove(in T item)
    2. {
    3.     int index = IndexOf(item);
    4.     if(index < 0)
    5.         return false;
    6.     RemoveRange(index, index+1);
    7.     return true;
    8. }
    There should be simple RemoveRange(index, 1); since RemoveRange accepts number of items to remove as second argument, not end of range.

    I could not find any way to report it directly to Unity.Collections team, I hope this is not so wrong place to do so.
    It can be observed in sources of newest com.unity.collections@0.5.0-preview.9.
    For reference, description from docs:
    Searches for the specified int from the begining of the FixedListInt128 forward, removes it if possible, and returns true if the int was successfully removed.
     
    Last edited: Jan 23, 2020
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,684
    I already reported it to them, same thing not only with Remove but with Insert also.
     
  3. bryanmcnett

    bryanmcnett

    Unity Technologies

    Joined:
    Aug 16, 2018
    Posts:
    12
    Thanks for the bug report, we just made a fix. It should go out with the next version of Collections.
     
    R2-RT and eizenhorn like this.