Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

t4 "using" keyword

Tags:

c#

c#-4.0

t4

I'm new with t4.

I would like to generate code to cs file. I created a new tt file.

<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".cs" #>

class IOperation {

<#
OperationSection section = null;

#>
}

OperationSection is a class in the same assembly. I assume that I should use the "using" keyword.

How I do it? Now I receiving an error

Error 2 Compiling transformation: The type or namespace name 'OperationSection' could not be found (are you missing a using directive or an assembly reference?)

thanks

like image 679
Guy Avatar asked Mar 28 '26 10:03

Guy


1 Answers

Use the import directive:

<#@ import namespace="YourNamespace" #>

Additionally, you might need to add an assembly directive to reference the assembly the class is defined in:

<#@ assembly name="$(SolutionDir)\MyProject\bin\Debug\SomeLibrary.Dll" #>
like image 120
Daniel Hilgarth Avatar answered Mar 29 '26 23:03

Daniel Hilgarth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!