AArnott / CodeGeneration.Roslyn

Assists in performing Roslyn-based code generation during a build.
Microsoft Public License
408 stars 60 forks source link

Shaking the reference assemblies tree #142

Closed mwpowellhtx closed 5 years ago

mwpowellhtx commented 5 years ago

@AArnott Best I can figure, the registry of assemblies used during code generation is only ever glommed on to. That is to say, the list is read, the loaded assemblies are appended, and it is re-saved. See LoadAssembly and SaveGeneratorAssemblyList. As internal and external dependencies adjust, grow, shrink, etc, over the course of a project, does this tree ever get shaken in order to discard stale code generation references?

mwpowellhtx commented 5 years ago

Possibly GetLastModifiedAssemblyTime is working around that concern. However, I am pretty sure the assembly registry would still grow and never be shaken.

AArnott commented 5 years ago

Are you asking about incremental build and the inputs/outputs check that it does? If so, you're quite possibly right. It's been so long since I looked at it. I probably didn't consider it a priority to make sure that incremental build over the long haul (with no clean/rebuilds along the way) didn't grow heavy on the regenerate-unnecessarily side.

amis92 commented 5 years ago
  1. We're talking about a list, not a tree
  2. GetLastModifiedAssemblyTime is only used to regenerate the file if the source didn't change but generators did.
  3. Nothing is discarded.

It probably requires fixing. Although whole incremental build support definitely needs fixing, and quite honestly, while using the generators I've come to a conclusion that the incremental build just doesn't work for me. Often my code generation depends not only on a given source file, but also on the base class's source, leading me to conclusion that it should be at least possible to completely disable incremental-ish computations inside the tool, or even drop them completely since they have so many issues.

The tool is invoked anyway, and the time of doing the Compilation is considerable. It'll probably need profiling, but I'd guess that creating Compilation (loading all Roslyn DLLs etc.) is considerably more expensive than any following code generation.

Sorry, I think I derailed. 😅😇👀

mwpowellhtx commented 5 years ago

@amis92 No worries. I'm recasting the execution on the implementation anyway, so this is quite informative, something I can keep my eyes open for.