T4 Template Generator rebuilt for Net Core

Viewed 941

I am working on a T4 template generator for Visual Studio that supports the net core runtime. The following requirements are

  1. T4 templates using netstandard 2.0 or netstandard 2.1 function assemblies.
  2. Support the latest language compiler.
  3. Debug T4 Templates in visual studio.
  4. generate T4 templates in visual studio via custom tool

That being said, what VS 2019 provides out of the box:

  1. T4 Template engine running on the Framework runtime.
  2. Roslyn in process compiler is limited to C# 5.0.
  3. Visual studio uses remote services to execute the template generation in a T4 host process, to attach too and debug the template.
  4. netstandard 2.x function assemblies are not supported, at least I could never get them to work.

Some of the considerations I have to account for are:

  1. netcore and net 5, do not support AppDomain.
  2. The T4 text transformation compiled with rosyln can not process in the framework, will not load the System.Private.CoreLib. this requires that a host process exist not only to generate the code files but also to debug them as well.
  3. This also means that the T4HostProcess uses named pipes to communicate with Visual Studio. Is the Host Process the named pipe server or is it the client. I want to say the server, but I am not sure, that is why I am posting this on stack overflow.
  4. With the last statement, I am pretty sure that I have to find a way to facilitate cross domain communication using named pipes, between a .net core process and a framework process(visual studio). Remote services is not an option because it was built for framework and will not work for .net core.

Steps taken to arrive to a solution:

  1. using the Mono T4 template engine to compile the T4 Transform assembly, using the netcore runtime of Roslyn.
  2. I have been able to accomplish the following: custom tool, compile a T4 transformation assembly.

I would love to hear about any suggestions on how I can get this working. I am in the weeds with this and some of them look downright daunting.

0 Answers
Related