Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for assembly based (single) templates #20

Closed
pauldeen79 opened this issue May 18, 2023 · 0 comments · Fixed by #26
Closed

Add support for assembly based (single) templates #20

pauldeen79 opened this issue May 18, 2023 · 0 comments · Fixed by #26

Comments

@pauldeen79
Copy link
Owner

pauldeen79 commented May 18, 2023

Currently, we support the following types:

  • Single template, parsed from text and then compiled into a single class in an assembly which can be executed
  • Code generation assembly, with multiple code generation providers that are all run and put into a MultipleContentBuilder

We want to add this type:

  • Single template, referred to using an assembly name and class name

This type can be a simple template, or internally use a MultipleContentBuilder and return that. The differences are:

  • The template is already compiled into an assembly, and doesn't need to be parsed (which gives you far better performance)
  • You can include multiple resources, assembly references and so on. These don't have to be resolved at run-time

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:

  • Single file, which is useful for example for global templates. Just store the dll (and possible nuget package reference dlls) in one directory, no need for a tree structure with includes or child templates
  • Better performance, no need to parse and compile
  • Can also be packed into a nuget package (maybe we can add support for this later... t4plus install https://nuget.org/mytemplate --version 1.0.0

You can use these assembly templates for both running and extracting parameters.

@pauldeen79 pauldeen79 linked a pull request May 23, 2023 that will close this issue
@pauldeen79 pauldeen79 changed the title Add support for assembly-based (single) templates Add support for assembly based (single) templates May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant