I am trying to create several linings for classes CRUDand would like to use T4 to help create these classes. I am just getting started and have a problem causing a class that lives in the same project. Example:
CRUD
<#@ import namespace="System.Collections.Generic" #> <#@ template language="C#" #> <#@ output extension=".cs" #> <#@ include file="T4Toolbox.tt" #> using System; using System.Data; using System.Data.Linq; using System.Collections.Generic; namespace TTFileGenerator { <#var entityName = "TEST";#> public class <#=entityName#> { <# MyClass myClass = new MyClass(); List<string> something = myClass.GetSomething() ... #> } }
Error:
Conversion compilation: MyClass namespace type or name could not be found (do you miss the using directive or assembly references?)
This is an open class in the same project. I can access it from other classes in the project, and not to the T4 file. Still new to T4. Any direction will be appreciated.
What you want to do will not be straightforward.
T4 ( MyClass), , T4 ( , EF). , , , T4 ( IDE ). t4 dll, . Visual Studio . < & GT;
, , (3 ). , , MyClass. .
( ) runtime t4 . ( MyClass) , , , ! .
. .
Aspect Oriented Programming (AOP). , , .
, . . .
, , , .
, , . (VS 2012)... , - T4:
//Reference to another project (for testing, it lives in the debug folder) <#@ assembly name="$(SolutionDir)\MyAssembly\bin\x86\Debug\MyAssembly.dll"#> <# var helper = new Utilities.MyHelperClass(); #> <# var something = helper.GetSomething(param1, param2); #>
Source: https://habr.com/ru/post/1530097/More articles:Inheritance and private variables - javaBest way to migrate SQL CE 4.0 database to Azure Sql - sql-server-ceFind the largest continuous sum, so its minimum and its complement are the largest - algorithmScala неявный параметр null, когда неявный val определяется после вызова метода - scalaHow to use error handler callback in Sails.js policy? - node.jsHow to use callback array as handler for Sails.js route? - node.jsКак экспортировать Windows Scheduled task history - windows-schedulerThere are no project DLLs in the "Modules" window - c #Regression prediction estimation - pythonUsing Jackson2 with Spring 4.0 (MVC + REST + Hibernate) - javaAll Articles