none
.NET Compiler Platform - Language-Agnostic Code Generation with Roslyn RRS feed

  • General discussion

  • Learn how to perform language-agnostic code generation using the Roslyn SyntaxGenerator class and its methods, which provide a unified programming model to generate syntax nodes that can target both C# and VB simultaneously.

    Read more in the June issue of MSDN Magazine

    Wednesday, June 1, 2016 7:02 PM
    Owner

All replies

  • Is it possible to generate XML documentation syntax trivia or nodes in a language-agnostic way too?
    Saturday, August 6, 2016 3:51 PM
  • I notice that the

    var generator = SyntaxGenerator.GetGenerator(workspace, LanguageNames.CSharp);

    has no methods to generate foreach blocks was this as it is only for use with a unified programming model?

     foreach (var vv in ChangeConditionSet)
      {   ...   }

    What is the best way to generate such elements from an add-hoc workspace?


    --Saul Scudder

    Tuesday, July 18, 2017 5:46 PM
  • This is very interesting to me. I've got a case where I want to inject generated code at compile time for otherwise VERY boilerplate code the developer would have to write. I gather I can introduce a Document based SyntaxGenerator and connect the dots in this way. Do I have to be concerned with saving the file at all? Adding the generated code to the project during compilation? For instance, I'd like for there to be some sort of artifact saved at least that the developer can review what was generated, and so on. Thanks for the insightful article!
    Saturday, May 12, 2018 7:15 PM