does roslyn support incremental compilation?

Topics: APIs, General
Oct 8, 2014 at 1:32 PM
hello,

i'm trying to determine if roslyn can do incremental compilation and detect the minimum set that needs to be compiled.

Said otherwise, is it already part of the tooling that one could programatically compile an Visual studio solution, then watch for file changes and only compile the stuff that has changed?

I know one could build it using the APIs, but i was wondering if any such support is already baked in.
Developer
Oct 8, 2014 at 6:33 PM
Roslyn supports incremental parsing and maintains an incrementally updated symbol tree which is used in Visual Studio while you are typing. Roslyn also supports lazy evaluation, so interactive services only need to do as much work as necessary to answer a semantic question. However, there is no incremental emitting of assemblies. When you choose build in Visual Studio only the assemblies dependent on recent changes are built, so it is incremental in that sense, yet for the assemblies that are built it is a full compilation. In fact, the Roslyn model of your source code that Visual Studio uses while you are typing is a completely separate instance of the model that is used when you choose to build. The build actually happens in a separate Roslyn build server process.
Oct 10, 2014 at 10:14 PM
But surely I can emit only a method? For my research project I'm trying to "ungenericize" methods of Foo<T> to something like FooT1, FooT2 ...

And it's so slow whenever I find a bug and want to recompile to ask Roslyn to compile the whole project, when only my method changed. Why can't I do this? It seems like Roslyn is using CCI underneath, and it can be done in CCI no problem.
Developer
Oct 22, 2014 at 11:26 PM
Edited Oct 22, 2014 at 11:26 PM
haliving wrote:
But surely I can emit only a method? For my research project I'm trying to "ungenericize" methods of Foo<T> to something like FooT1, FooT2 ...

And it's so slow whenever I find a bug and want to recompile to ask Roslyn to compile the whole project, when only my method changed. Why can't I do this? It seems like Roslyn is using CCI underneath, and it can be done in CCI no problem.
The main reason is that our symbol tables are immutable. From any symbol you can reach most other symbols in the assembly. Even adding a comment changes the symbols, because each symbol has a Locations property that gives the source location(s) where it was defined. So we need to generate an entirely new symbol table when things change.