I have some ideas for code ECS analysis that ReSharper may support.
-Native Containers disposing
-Checks if JobHandle is passed to CommandBufferSystem using AddJobHandleForProducer(handle)
Agreed, ECS has a number of easy pitfalls which some static analysis would really help on. Alongside what you have suggested, I would also suggest:
IJobForEach based jobs, suggest ReadOnly and WriteOnly attributes as appropriate for components.IJobForEach based jobs, suggest moving components not read from or written to a RequireComponentTag attribute (not using it or ReadOnly is an error for completely empty components).ReadOnly attribute and writes to the container/component. Likewise for WriteOnly and reading.readonly and then the writes to the container.ComponentDataFromEntity is used to read/write an empty component (Exists() is OK, however).JobHandles that are ignored.ParallelWriters in parallel jobs.NativeList is passed to a job as a NativeArray without using AsDeferredJobArray() where it has been potentially written to by another job.IJobParallelForDefer based job is scheduled with a NativeList that isn't passed into the job.ComponentDataFromEntity type is marked as ReadOnly in a job, but the GetComponentDataFromEntity call doesn't give the isReadOnly argument true.Allocators (e.g: using Allocator.Persistent for a native collection defined in a using statement, and so disposed of in the Temp timeframe).
Most helpful comment
Agreed, ECS has a number of easy pitfalls which some static analysis would really help on. Alongside what you have suggested, I would also suggest:
IJobForEachbased jobs, suggestReadOnlyandWriteOnlyattributes as appropriate for components.IJobForEachbased jobs, suggest moving components not read from or written to aRequireComponentTagattribute (not using it orReadOnlyis an error for completely empty components).ReadOnlyattribute and writes to the container/component. Likewise forWriteOnlyand reading.readonlyand then the writes to the container.ComponentDataFromEntityis used to read/write an empty component (Exists()is OK, however).JobHandlesthat are ignored.ParallelWriters in parallel jobs.NativeListis passed to a job as aNativeArraywithout usingAsDeferredJobArray()where it has been potentially written to by another job.IJobParallelForDeferbased job is scheduled with aNativeListthat isn't passed into the job.ComponentDataFromEntitytype is marked asReadOnlyin a job, but theGetComponentDataFromEntitycall doesn't give theisReadOnlyargumenttrue.Allocators (e.g: usingAllocator.Persistentfor a native collection defined in ausingstatement, and so disposed of in theTemptimeframe).