t4

T4 Code Generation missing in Visual Studio 2008?

时间秒杀一切 提交于 2019-12-02 18:15:33
问题 So I decided to roll up my sleeves and try out the T4 code generation built into VS2008. I was going to work off of this article: http://www.olegsych.com/2008/09/t4-tutorial-creatating-your-first-code-generator/ So, I get to this part: "Click Project->Add New Item in the main menu and select Code Generation->File template in the dialog." and discover that the Code Generation category is missing on my machine. (Tried in both a VB and C# project). Is there perhaps a seperate download to get T4

how can I get intellisense in a T4 template? [closed]

落爺英雄遲暮 提交于 2019-12-02 17:51:45
When trying out these tutorials ( T4 Tutorial: Creating reusable code generation templates ) I noticed that although I was using plain c# I didn't get any intellisense, probably because of the file extension (.tt) Isn't there anyway to say to Visual Studio to consider those .tt files as .cs files and thus get the correct intellisense help? Oleg Sych You can purchase the professional version of T4 Editor. It works very well in standalone .tt files, but unfortunately, due to the differences in how the pro version of T4 Editor and T4 itself compile the templates, you will get false errors

How can I use Linq in a T4 template?

夙愿已清 提交于 2019-12-02 17:22:54
I am using T4 to generate some screens and middle-tier code for a project, and would like to use Linq to simplify some of my template code. However, when I try to use Linq, the template reports a syntax error. GalacticCowboy By default in Visual Studio 2008 (and as used in most online examples) the template is compiled with the 2.0 Framework, which does not include Linq. (See MSDN forum thread ) To solve the problem, three steps are needed: In your template's language attribute, specify "C#v3.5" or "VBv3.5" - this step is not required for VS2010, where .Net 4.0 is always used. Add an assembly

Code Generators or T4 Templates, are they really evil?

独自空忆成欢 提交于 2019-12-02 17:20:35
I have heard people state that Code Generators and T4 templates should not be used. The logic behind that is that if you are generating code with a generator then there is a better more efficient way to build the code through generics and templating. While I slightly agree with this statement above, I have not really found effective ways to build templates that can say for instance instantiate themselves. In otherwords I can never do : return new T(); Additionally, if I want to generate code based on database values I have found that using Microsoft.SqlServer.Management.SMO in conjunction with

Get Project or Relative Directory with T4

泪湿孤枕 提交于 2019-12-02 16:08:10
How can I get a reference to the directory of the visual studio project or solution or the directory of the t4 template from within a t4 template? I have a template that concatenates a number of files together which are located relative to the template. I need to get a reference to there absolute location through a relative means. Hard coding an absolute path is not acceptable because the visual studio project will not always be in the same location and this would break the code generation. Reading the current working directory from the environment doesn't work either because that returns the

T4 Code Generation missing in Visual Studio 2008?

家住魔仙堡 提交于 2019-12-02 12:13:30
So I decided to roll up my sleeves and try out the T4 code generation built into VS2008. I was going to work off of this article: http://www.olegsych.com/2008/09/t4-tutorial-creatating-your-first-code-generator/ So, I get to this part: "Click Project->Add New Item in the main menu and select Code Generation->File template in the dialog." and discover that the Code Generation category is missing on my machine. (Tried in both a VB and C# project). Is there perhaps a seperate download to get T4 on your machine? Update #1 So, I downloaded the T4 Toolbox from CodePlex: http://t4toolbox.codeplex.com

Entity Framework EDMX - Entity Pluralization Fix

笑着哭i 提交于 2019-12-02 06:30:58
问题 We have found some bugs for certain words with the PluralizationService, for example it thinks "Campus" is plural, and it singularizes it by "Campu". Anyhow, we have figured out how to add custom mappings to the service using the ICustomPluralizationMapping interface, the problem is, how do we tell the EntityModelCodeGenerator to use our custom service instead of the base one? We are using EF 4.2 database first with custom T4 templates. 回答1: Maybe this article is helpful: http://blogs.msdn

VS2010 - Assign html code formatting to T4 (.tt) file

烈酒焚心 提交于 2019-12-02 03:20:45
I am having a T4 text template (.tt) in VS2010 - mainly used to generate HTML code (basically some includes and JavaScript). Is it possible to assign the HTML code formatting (colors, etc) to that tt file. Is situation (the T4): Want have: -- Update as of answer Marcio Barcellos -- Formatting with proposed AddOn: You can add an extension to visual studio and get the result you want http://visualstudiogallery.msdn.microsoft.com/40a887aa-f3be-40ec-a85d-37044b239591 来源: https://stackoverflow.com/questions/12355639/vs2010-assign-html-code-formatting-to-t4-tt-file

Retrieving fluent configuration programatically without instantiating DbContext

那年仲夏 提交于 2019-12-02 00:50:35
I have a DbContext derived class whose member entity classes are configured using Fluent API. I want to retrieve these configurations and relationships programatically. the code to do this is already in place and I am porting it to a T4 template for code generation. While most of the code generation uses reflection, fluent configuration requires the context class to be instantiated in order to get: ObjectContext EntityObjects EntityContainer EntitySets Etcetera Since we are not using property attributes, reflection is of no help. This works fine during runtime, but instatiating the DbContext

How can I use EnvDTE within a .NET Standard project

女生的网名这么多〃 提交于 2019-12-02 00:16:27
问题 I'm porting a .net 4.7 project to .net standard, which uses T4 to generate some code. I iterate over the classes, properties and methods. This use to work perfectly, but now the return types of DTE are of type 'System.__ComObject' and I cannot cast them. Error: Unable to cast COM object of type 'System.__ComObject' to interface type 'EnvDTE.CodeClass'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B1F42514-91CD-4D3A-8B25-A317D8032B24}'