(Case 1210245) Unity Editor crashes when using a generic component with the lambda API

I’m using the last version of Entities 0.5. Code for reproducing the issue is simple, and authoring is not required to see the crash:

[assembly: RegisterGenericComponentType(typeof(GenericComponent<int>))]
namespace Assets
{
    public struct GenericComponent<T> : IComponentData
    where T : struct
    {
        public float Value;
    }

    public class SystemWithGenericComponent : JobComponentSystem
    {
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            return Entities
                .ForEach((in GenericComponent<int> cGeneric) =>
                {
                    // Some work...
                }).Schedule(inputDeps);
        }
    }
}

After running any scene the Editor crashes immediately. The editor log shows some exception in Mono:
* Assertion at ..\mono\mini\method-to-ir.c:8462, condition `!mono_method_check_context_used (cmethod)' not met

So, if I have Entities.ForEach with a generic component, the entire project will broken. Jobs as structs with generic components are working properly.

1 Like

I’m sorry I unintentionally created the thread in wrong subforum. Can anyone move the thread to DOTS subforum?

I can reproduce this. I found another post about Generics in lambdas being unsupported, but the editor crashing seems a bit much!