#Trying to upgrade to 6.2. TypeIndex of a generic buffer element have different results.

1 messages · Page 1 of 1 (latest)

crimson herald
#

I have this problem that I posted on the Unity ECS forums. https://discussions.unity.com/t/trying-to-upgrade-to-6-2-typeindex-of-a-generic-buffer-element-is-different/1678487

I have narrowed it down to this test:

    [Test]
    public void DynamicBufferHashMapTypeTest() {
        // Fails
        TypeIndexEqualityTest<DynamicBufferHashMap<ConditionId, bool>.Entry<bool>>();
    }
    
    [Test]
    public void SampleTypeTest() {
        // Succeeds
        TypeIndexEqualityTest<GenericStruct<ConditionId, bool>.InnerElement<bool>>();
    }

    private static void TypeIndexEqualityTest<T>() {
        Type type = typeof(T);
        TypeIndex usingType = TypeManager.GetTypeIndex(type);
        TypeIndex usingGeneric = TypeManager.GetTypeIndex<T>();
        Assert.AreEqual(usingType.Index, usingGeneric.Index);
    }

    // Just a sample
    public struct GenericStruct<T, U> : IComponentData 
        where T : unmanaged, IEquatable<T>
        where U : unmanaged, IEquatable<U> {
        public T t;
        public U u;
        
        public struct InnerElement<T> : IBufferElementData where T : unmanaged, IEquatable<T> {
            public T t;
        }
    }
}

This used to work in Unity 6.1. Not sure if this should be a bug.

sly helm
#

are you saying this changed in 6.2 with same entities version?

#

what version of entities

#

are you registering the generic component somewhere

crimson herald
#

Yes, same entities, 1.3.14. Yes, I registered the component somewhere because otherwise, this test won't run. I'm about to file a bug report.

tired glacier
#

@crimson herald what's your bug number? this is almost certainly my fault but i can't find the bug searching

crimson herald
#

According to our email exchange, it's IN-112820

tired glacier
tired glacier
#

@crimson herald for me, the test fails with System.ArgumentException : Unknown Type:`CommonEcs.DynamicBufferHashMap`2+Entry[CommonEcs.Goap.ConditionId,System.Boolean]` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType]. and if i add ```[assembly: RegisterGenericComponentType(typeof(DynamicBufferHashMap<ConditionId, bool>.Entry))]

crimson herald
#

Did you check the project? Not sure if you could see the email exchange I had with Julius but he asked me to upload the project and I did. I have the test there as well and that fails. There's something in the project that makes it fail but I couldn't find it. When the test is executed in an empty project, it succeeds.

tired glacier
crimson herald
#

How did you register it? Because it was already registered in AssemblyInfo.cs. Otherwise, the test won't execute if it wasn't registered.

crimson herald
#

I also uploaded two projects. The first one was wrong because I forgot the external modules. The second upload should already be working when opened on Unity 6.2.

tired glacier
crimson herald
#

I just opened the uploaded project and see here that it fails.

#

They are registered in Game/Scripts/Assembly/AssemblyInfo.cs

#

Interestingly, it only fails in the project. It succeeds when the test is run in isolation.

tired glacier
crimson herald
#

It's quite big. It's beyond the limit here.