Missing assembly reference errors in generated code

Hi,

I’m migrating from 0.17 to 1.0. I’ve replaced and updated all the relevant parts of the code, so in my IDE, everything passed from red to green. However, in Unity, the generated code of my systems doesn’t seem to be aware of any Unity dependencies, or at least not of the package dependencies.

Temp\GeneratedCode\VisualPinball.Unity\ContactSystem__System_805436689.g.cs(25,50): error CS0234: The type or namespace name 'Entities' does not exist in the namespace 'VisualPinball.Unity' (are you missing an assembly reference?)

I got tons of those, mainly about Mathematics, Burst, Collections, Jobs, Profiling and Entities as seen in the log.

It’s an open source project, so anyone should be able repro (source, install instructions).

Any hints or suggestions would be appreciated.

EDIT: I forgot to mention that the DOTS code is in a package, not in the main project. I don’t know if that makes any difference (it shouldn’t, IMO). The entities dependency is also in that package.

This is very likely related to the fact that your namespace is “VisualPinball.Unity” and Unity packages generally have “Unity.X” - it’s probably bad resolution to “VisualPinball.Unity.X” which would have been avoided by prefixing the source generator produced sources with global:: to avoid resolving to something else. In general, you should avoid namespace structures that reuse a name that has meaning somewhere else, renaming to VisualPinball or VisualPinballUnity would probably fix the source generator output.

1 Like

Oh boy… I renamed the namespace in a few classes and it indeed seems to fix the problem.

Do you know why the generator doesn’t use global::? This is a bug, right?

Yeah, it’s a bug. I’m guessing this is just an oversight. As far as I know, you wouldn’t lose anything with explicit global:: applied liberally. It’s cases like this which trip things up. If I were you, I’d consider sending a bug report explaining your use case. It would be better to ask for changes along these lines with a popular git repo as context than with a contrived example :stuck_out_tongue:

1 Like

Great, thanks. @LaurentGibert which channel for an ECS bug report do you prefer?