t4

A generic method can use contravariant/covariant types?

爱⌒轻易说出口 提交于 2019-11-30 14:12:59
问题 I'm writting a generalized method to use it in a special task at a T4 template. The method should allow me to use specialized types from a general interface. I thought about the following signatures: interface IGreatInterface { Object aMethodAlpha<U>(U parameter) where U : IAnInterface; Object aMethodBeta(IAnInterface parameter) } public class AnInterestingClass : IAnInterface{} When I try to implement IGreatInterface the compiler flags an error for aMethodBeta() because I've made my T4 to

Where can I find the API specification for MvcTextTemplateHost?

一个人想着一个人 提交于 2019-11-30 13:56:17
I'm trying to use a custom T4 template for adding new Controllers to a MVC 3 project. I have my own template as Scott Hanselman wrote on http://www.hanselman.com/blog/ModifyingTheDefaultCodeGenerationscaffoldingTemplatesInASPNETMVC.aspx , but I'm interested in digging a bit more in the MvcTextTemplateHost Class to see what else it offers, so we can customize a bit more our controllers, and see how does it interact with the "Add controller..." dialog. But I cannot find (after searching at Google, of course...) the reference to this class, nor MSDN either any other MS site... any ideas? Thanks,

Text Transformations & Finding Entity Plural (Collection)

情到浓时终转凉″ 提交于 2019-11-30 12:54:34
问题 If I have a .tt template, I can use entity.Name to write out the name of an entity, e.g: foreach (EntityType entity in ItemCollection.GetItems<EntityType>().OrderBy(e => e.Name)) {; WriteLine(entity.Name); } Using normal transformations or T4, How do I write out the actual name of the entity set? (E.g. for Person, it might be Persons - but maybe I changed it to People in the designer, so I'd want that instead). Thanks! Richard 回答1: I was looking for the answer to the same question and found

Why does my T4 template append a number to the file name?

丶灬走出姿态 提交于 2019-11-30 12:37:07
问题 Why do my T4 templates sometimes append a number to the output file and sometimes not? For instance, in one case I might have a template file called Foo.tt and I'll get an output file of Foo.cs . In other cases, I'll get an output file of Foo1.cs . In every case, there is no other Foo.cs file that might be causing it to append a number. In other words, it is definitely not the result of any obvious file name conflict. I'm a deeply anal retentive developer, so I'd sure love to know how to get

How can I resolve this error: Loading the include file 'EF.Utility.CS.ttinclude' returned a null or empty string

走远了吗. 提交于 2019-11-30 12:32:44
问题 How can I resolve these errors: Loading the include file 'EF.Utility.CS.ttinclude' returned a null or empty string. Value does not fall within the expected range. Tools Used: VS 2012, Entity Framework 5.0.0, T4MVCExtensions 3.5.0, .NET Framework 4.5 I've been using EF and T4 templates in a project within a large MVC solution without incident. Now, when I right-click on the edmx diagram, EF responds with the message: Value does not fall within the expected range. When I compile the EF project

How can I customize WCF client code generation?

不羁的心 提交于 2019-11-30 09:45:48
Are there any tools or code generation templates that will let me customize and extend the WCF cliend proxies? It's not that svcutil is horribly broken, but rather I'd like to be able to generatate additional code based on the service contract, not just be limited the svcutil output. John Saunders Have you looked at the Web Service Software Factory ? It allows you to have complete control over the generation of proxy code. I've since found two other options: wscf.blue WCF Proxy Genererator There are several T4 templates available around the web. Here are some : http://www.codeproject.com/KB

How do you use .net Reflection with T4?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 08:42:34
I have a c# project which includes a Text Template. I would like this template to generate some SQL based on reflecting against the C# classes in the project. How does one access the current project's contents using T4? Is it possible, and if so, is Reflection available, or is it access to just the raw source that must then be parsed? Thanks in advance! How does one access the current project's contents using T4? One way is to use the EnvDTE COM component. Googling T4 and EnvDTE should bring back plenty of examples. Is it possible, and if so, is Reflection available, or is it access to just

T4 template and run-time parameters

流过昼夜 提交于 2019-11-30 07:18:09
I am building a plug-in in VS 2010 and I get stuck at the T4 generation. Right now I have implemented (like MSDN suggests) a custom T4 host to generate my T4 results and I use it in this way: const string content = @"c:\Simple.tt"; var engine = new Engine(); var host = new MyTemplateHost(); var result = engine.ProcessTemplate(File.ReadAllText(content), host); foreach (CompilerError error in host.Errors) { Console.WriteLine(error.ErrorText); } This works until I pass a parameter in the Template. As soon as I create a parameter in the .tt file, the Host freak out saying that it doesn't know how

TFS Hosted Build Controller - Microsoft.TextTemplating.targets not found

核能气质少年 提交于 2019-11-30 04:48:30
问题 I've been debugging an issue for a day now and can't seem to figure it out. Perhaps someone else has run into something similar and can shed some light? We've configured all T4 templates within a project in our solution to run when the project is built, as in shift-ctrl-b . This works great - it required us to add this import statement to the project .csproj file: <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\TextTemplating\Microsoft.TextTemplating.targets"/> We've

How to use T4 code generation templates with VS C++ projects?

∥☆過路亽.° 提交于 2019-11-30 04:09:49
T4 template files are automatically recognizable by the IDE under C# projects, but I have no clue on how they can be integrated into C++ projects (other than using make files). Any ideas? Logan5 T4 Template files can be integrated into C++ projects, but it's a bit more work than with a C#/VB project. Create a new text file in your C++ project and give it a .tt extension. Then write your template as normal. A C++ project then needs further work to get it to transform the templates. The quick and dirty way I got it to work was to add a custom build step and have it call "C:\Program Files\Common