What is the equivalent of c# syntax analysis in razor?

I wanted to know if it exists an equivalent of Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree for razor or cshtml documents.

My goal is to generate razor document dynamically, and I don’t want to do this manually via string concatenation.

I searched for this ability but I only found CSharp and VisualBasic syntax tree available in the documentation

  • “Microsoft.CodeAnalysis” is for analyzing existing code, not generating code – exactly how do you propose to use it to generate razor documents?

    – 

  • It seems to be possible to generate source code from CSharpSyntaxTree by calling .ToString() method, wright ?

    – 

Leave a Comment