1

In earlier versions of Visual Studio (prior to the roslyn preview), a custom build task did not have access to the parse tree or the semantic model of the c# compiler. Do we have access to these structures in custom build tasks (or something equivalent to custom build tasks) in the new "Roslyn" based Visual Studio "14" CTP?

I.e. can you do something similar to a custom build tasks that can not merely read the text of the source code file, but also access the C# SyntaxTree and the .NET/C# SematicModel employed by Visual Studio "14" CTP during the build?

I failed to locate help files or documentation for the Visual Studio SDK for the "14" CTP build. Are there any documentation to be found?

Motivation

I want to build a code generator (made popular with XAML and other partial class/code behind paradigms) that have access the SemanticModel (i.e. the typed code graph) of the CSharp compilation. I currently have a code generator that parses the source code file using mono Cecil, but this of course only gives be access of the syntax tree of the single file have the custom task and not the entire tree or resolved graph of entire CSharp/.NET compilation.

Lennart
  • 9,657
  • 16
  • 68
  • 84
Jack Wester
  • 5,170
  • 3
  • 28
  • 47
  • The answer [here](http://stackoverflow.com/a/7839398/517852) (esp the recent comments) indicates that there aren't direct hooks into the compiler for doing rewriting/code-gen at compile time. It seems the best you could do is a pre-build step that uses the Roslyn APIs in a separate compilation. – Mike Zboray Jul 08 '14 at 08:24
  • You might be interested in reading up on [the CodeDOM](http://msdn.microsoft.com/en-us/library/y2k85ax6(v=vs.110).aspx). – Jeroen Vannevel Jul 08 '14 at 08:52
  • 1
    @Jeroen This does not really apply to the SemanticModel or SyntaxTree of Roslyn – Jack Wester Jul 08 '14 at 09:18
  • @JackWester: indeed it doesn't but it is an alternative approach since Roslyn isn't really intended for code generation but rather code manipulation. – Jeroen Vannevel Jul 08 '14 at 09:35

0 Answers0