pauldeen79 / texttemplatetransformationframework Goto Github PK
View Code? Open in Web Editor NEWStand-alone T4 compatible template engine
License: MIT License
Stand-alone T4 compatible template engine
License: MIT License
Using this, you can call t4plus run --short-name from any directory on your computer for code generation.
Run, sourcecode, extract templates and code generation assembly commands should support watch argument
-w|--watch
Optional class name filter for code generation provider command.
Currently, all code generation providers are run. You should be able to provide (multiple) class names for filtering.
Currently, we support the following types:
We want to add this type:
This type can be a simple template, or internally use a MultipleContentBuilder and return that. The differences are:
We have to think of a command to run this template. Or maybe just think of a name for this kind of template.
What about t4plus run -a project\bin\debug\my.dll -t MyNamespace.MyClass Arg1:Value1 Arg2:Value2
-a | --assembly
-t | --type
-u | --use directory (optional)
In the run command, either the filename or the assembly and typename are required.
Advantages:
You can use these assembly templates for both running and extracting parameters.
This makes it possible to use it from the command line. For example, you can pipe the bare output to the clipboard. Or even let the t4plus command-line tool copy it to the clipboard for you.
Maybe it would be a good idea to generate a .csproj file on the fly, calling dotnet build to generate an assembly and all nuget references in a temporary directory. This way, we don't have to store assemblies in the temp folder, and this also fixes resolving assemblies from nuget packages. (do we need "lib", or which target framework do we need?)
Edit: Maybe it would be a better option to use assembly templates. You can do whatever you want, just copy all the package binaries to the output directory and use that as probing path. (is already performed when you use the file name of the assembly)
When using T4Plus, if you have a template that doesn't have the template directive, then you get an exception in the template factory. (after compiling the assembly, and trying to render the template)
Also, the Initialize method does not include any code. This is wrong.
In the token parser, a template directive should be inserted if it's not found. This will fix this issue.
For example, t4plus assembly src\codegeneration\bin\debug\net7.0\codegeneration.dll
This runs all ICodeGenerationProvider instances from codegeneration.dll. If we need command-line options, add them to the command. (I can think of DryRun and Path)
The command will detect all code generation providers using reflection.
The assembly command needs to be improved in two ways:
Using these two improvements, you can now simpy use t4plus assembly -a myproject\bin\debug\net7.0\myproject.dll
Instead of t4plus assembly -a c:\fullpath\myproject\bin\debug\net7.0\myproject.dll -p c:\fullpath\myproject\bin\debug\net7.0
Use C# raw string literals instead of T4 for templating.
If this works, we can remove all T4 stuff and the template parsing (token) stuff.
What will remain, is just the Runtime project (without template specific stuff) and the Cmd project (without template specific stuff)
Advantages:
The proof of concept needs to include this:
See for more info:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/raw-string
https://devblogs.microsoft.com/dotnet/csharp-11-preview-updates/
Rename t4plus to template
After this, you can do this:
template run mytemplate.template
On the other hand... Is this really necessary?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.