Vixen
dd8b0a81
csharp
public sealed class InferAccessAttribute

Asks the generator to read this system's access out of its own query bodies and emit the declaration.

No guide page documents this yet — the page shows what the code says about itself.

As a annotation

Valid on
Class

Remarks

The system has to be a partial, non-generic, top-level class implementing ISystem; the generated half implements IDeclaredAccess. That is the interface rather than the attributes deliberately — SystemAccess.Declare().Write<Position>() closes a generic and so assigns Position its component id, where an attribute can only look one up and there is nothing to look up until something has stored one.

⚠ Opt-in, and it is not a formality. Inference can only see what the class itself says: a query the system builds by calling a helper in another assembly is invisible to it, and an under-declared system is a data race rather than a slow one. Marking a class is the author's statement that its access is visible in its own body.

⚠ "The class itself" is the whole class, and what leaves it is now reported. Every invocation under the class's own declarations is walked, so a private helper, a local function and the other half of a partial are all seen. What is outside is a base class, another type and another assembly — and a call that carries a World, Chunk, CommandBuffer, CommandBuffer.ParallelWriter or SystemContext into one of those is VXS0412, at the call site. It used to be silent, which made an under-declared system indistinguishable from a correctly declared one. Not caught: a world handed to a constructor, which is an object creation rather than an invocation.

⚠ Where the direction is not knowable it errs towards writing. The delegate and visitor forms take every component by ref whether or not the body assigns through it, so their type arguments are inferred as writes. The chunk form distinguishes them, because Values<T> and ReadValues<T> are different calls. Over-declaring costs parallelism; under-declaring is the bug.

An explicit ReadsAttribute or WritesAttribute on the same class overrides this: the generator emits nothing and says so, rather than leaving two declarations where only one is read.

Used by (3)

  • InferredChunkSystemVixen.Engine.Tests
  • InferredDelegateSystemVixen.Engine.Tests
  • InferredFilteredSystemVixen.Engine.Tests