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

dotnet-t4: Use -c without specifying class name #129

Open
bricelam opened this issue May 3, 2022 · 3 comments
Open

dotnet-t4: Use -c without specifying class name #129

bricelam opened this issue May 3, 2022 · 3 comments
Labels

Comments

@bricelam
Copy link

bricelam commented May 3, 2022

I hate the redundancy of specifying commands like this to preprocess templates:

t4 -c MyTemplate MyTemplate.tt

I'd love to see a new option that infers the class name from the input file so I can just specify something like this:

t4 --preprocess MyTemplate.tt
@bricelam
Copy link
Author

Hmm, looks like you'd also need a way to specify the namespace.

Maybe this issue isn't really worth it in the end.

@mhutch
Copy link
Member

mhutch commented Oct 4, 2022

This seems reasonable to me - even if it's no more concise, eliminating redundancy helps reduce user error.

Maybe just t4 -n SomeNamespace SomeClassname.tt ?

@mhutch mhutch added the feature label Oct 4, 2022
@zha999
Copy link

zha999 commented Jan 11, 2023

@bricelam
If you are add command in project config file (e.g. csproj), you may try the method of https://github.com/nogic1008/T4Sample.

<Exec WorkingDirectory="$(ProjectDir)" Command="dotnet t4 %(TextTemplate.Identity) -c $(RootNameSpace).%(TextTemplate.Filename) -o %(TextTemplate.Filename).Generated.cs" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants