Using Generic components in IJobEntity?

In previous renditions of my setup, I had a component per message type (which there are a fair amount), where all of the components had a BlobAssetReference to their own type. This made the system easy to work with, but accrued quite a bit of technical debt whenever a new message type was to be added.

I recently updated to 1.1-exp and noticed that somethings have changed, such as using ISystems with generics. This is extremely helpful and I was able to simplify a blob disposal method that cut down on the amount of boilerplate without sacrificing performance, but the final point now that is causing grief is using an IJobEntity with a generic component. Note, even at compile time, the component is known, but the source generated is having a problem handling it correctly.

Below is an example of how to cause Unity to spit out something along the lines of
error CS0426: The type name 'InternalCompilerQueryAndHandleData' does not exist in the type 'TestGenericComponentSystem.JobTestGen
This is a little unexpected given that Dynamic buffers are nearly the same thing in this regard. Is there something I can do, to have the generated source to be valid? The Job itself is not generic, only the component being used is. I can of course write this as an IJobChunk, but that seems overkill for something that is working on a different existing generic of a similar nature.

[BurstCompile]
public partial struct TestGenericComponentSystem : ISystem {
    public void OnUpdate(ref SystemState state) {
        state.Dependency=new JobTestGenericComponent().ScheduleParallel(state.Dependency);
    }

    public struct Blob  {
        public int K;
    }
  
  
    [BurstCompile]
    public partial struct JobTestGenericComponent : IJobEntity {
        private void Execute(in BlobComponent<Blob> blobComponent) {
        }
    }
  
    [BurstCompile]
    public struct BlobComponent<T> : ICleanupComponentData, IDisposable where T : unmanaged {
        public ref T Value => ref _blob.Value;
        private BlobAssetReference<T> _blob;

        public BlobComponent(BlobAssetReference<T> blobRef) {
            _blob = blobRef;
        }

        [BurstCompile]
        public void Dispose() {
            _blob.Dispose();
        }
    }
}

Do note, that this with Dynamic buffers work perfectly fine:

[BurstCompile]
public partial struct TestBufferSystem : ISystem {
    public void OnUpdate(ref SystemState state) {
        state.Dependency=new JobTestBuffer().ScheduleParallel(state.Dependency);
    }

    public struct BufferData : IBufferElementData {
        public int K;
    }
  
  
    [BurstCompile]
    public partial struct JobTestBuffer : IJobEntity {
        private void Execute(in DynamicBuffer<BufferData> blobComponent) {
        }
    }
}

I’m not sure if generics are already supported in IJobEntity. Bite the bullet and use IJobChunk. More verbose but definitely not overkill. IJobEntity would generate that same IJobChunk code. You’ll get the benefit of quicker compile time, too.

I don’t think compile time will really be any faster. It is 15 seconds without either at the moment due to domain reloads being abysmally slow. This was more for an asset I was making which a selling point is simplicity. Not really a good selling point if it requires a lot more boiler plate that is going to likely be very similar given certain types.

Actually this is a known issue for a while, now it’s either on the Entities team’s roadmap or they won’t support it at all. It all depends on the guy who is working on source generators.

As a side note for those running into this issue and have a need to use generics without writing a decent amount of boiler plate, it is possible to use Aspects to allow source generation to work with the IJobEntity and Generics. It seemingly works, but unsure if that is only in editor.