I’m in version 1.2.3.
Where are the .cs files? I’ve seen Library/GeneratedCode and C:/Users/…/AppData/Local… and Library/ScriptAssemblies…
When I write a JobEntity, it should be generating something, but Visual Studio isn’t showing anything under All References to that job. I have another project where it shows a generated cs file and my class, but it’s not happening in my new simple project.
Shouldn’t it be defining the IJobChunk for my job somewhere else? I need to see what it does to test something.
Where are the generated files in this version of ECS? Why isn’t it stated anywhere?
[EDIT] seems like in Visual, if you do “Go To Definition” on a partial struct, you’ll get the generated reference too. But you can’t open the code. (I could do this in the other project). It doesn’t have a path, and you can just see a sneak peek of the code for that definition but not the full generated code. How can I see it?
It’s weird that Visual Studio doesn’t show the source correctly. It’s Microsoft’s own tech stack, after all… Oh well. Works flawlessly in JetBrains Rider on my end.
You can add DOTS_OUTPUT_SOURCEGEN_FILES to scripting defines in player settings, but that slows down compilation. The point of previewing the codegen through the IDE is to avoid having to write everything to the disk during compilation. The IDE should be able to generate the source on demand.
Maybe regenerating the solution/project files would help?
For me in Visual Studio, if I right click on the job and choose “Go to definition”, I get two search results in the bottom. I can click on one of them and view the whole generated file. This works for both IJobEntity and IAspect. However, it does not work for systems, because Unity doesn’t play entirely by Microsoft’s rules when it comes to source generators for systems.
Code generation happens inside the compiler and the resulting artifacts aren’t stored on disk because they aren’t needed on disk under normal operation. For diagnostic purposes, this can be made to happen from MSBuild options in normal C# projects. Entities provides the DOTS_OUTPUT_SOURCEGEN_FILES symbol as an alternative. General info about source generators is available in the Microsoft docs, and there’s some Unity-specific info in the Unity docs.
Under Visual Studio 2022 17.11.0 (nobody here is mentioning which product version they’re using - this info is always useful) you can fall back to looking in the Solution Explorer under [Project] > References > Analyzers > [GeneratorAssembly] > [Generator]. All generated sources should be listed there.
New 6000.0.18f1 3D URP Core project with Entities 1.2.3 (includes VS editor package 2.0.22), C# projects in assembly definition and predefined assemblies: “Go to Definition” and “Go to Implementation” both work perfectly fine for navigating to the source-generated portion of IJobEntity and ISystem (double-click the entry with the generated code).
The only issues I encountered were “Peek Definition” pointing to a missing file on disk for the source generated file (where the disk-generated files from DOTS_OUTPUT_SOURCEGEN_FILES would go, under <Project>/Temp/, seems like a bug), and the system generator not producing anything when no augmentation / implementation replacement is needed which I presume is intentional and normal.
Deviation from expected behavior should be shown with specific examples and repro projects for reporting bugs to the relevant parties (depending on what breaks, Microsoft ([Visual Studio] > Help > Send Feedback > Report a Problem...) or Unity) or for others to confirm / advise on.
Seems to be happening randomly. Sometimes it finds the file sometimes it doesn’t. It just shows a sneak peek of it, but can’t open the actual file. Sometimes it can. Right now I’m able to , again… No idea what happened.
Thanks