Note that, I’m a PowerShell beginner. So my code could probably be written with a better way.

Also note that the GetProjects and GetAllProjectItems (used for Intellisense) are PowerShell commands defined by WAQS.

In order to update safely the ViewModel and the View, WAQS uses Roslyn. But I prefer using C# than PowerShell to do it.

So WAQS NuGet package brings a Console Application (coded in C#) and the PowerShell command executes it with arguments.

With WAQS logic, you should have a WAQS configuration xml file in the ViewModel project that describes WAQS generation including namespaces. So, using EnvDTE, NuGet PowerShell command determines the path of this file ($waqsFilePath), the project default namespace ($defaultNamespace) (used if configuration file does not set namespaces) and the path of Active document ($activeDocumentPath).

The Console Application read the ViewModel / View file, parse it using SyntaxFactory.ParseCompilationUnit, use a specific CSharpSyntaxRewriter to transform it and write the text associated to the SyntaxTree in the file.

Note that SyntaxNode.ToString method does not generate a code that compiles because spaces are missing. So you have to use mySyntaxNode.NormalizeWhitespace().ToString().