t4

EntityFramework t4 template - XML documentation

僤鯓⒐⒋嵵緔 提交于 2020-01-02 17:33:30
问题 I have the following problem with my EDMX file. In it I have written some Documentation for the properties as well as the Entities, but the t4 template of my EF 5 doesnt generate those values. My desired result should be public class Person { /// <summary> /// Hello World Summary!! /// </summary> /// <remarks> /// Hello World Remarks!! /// </remarks> public string Name { get; set; } } But I only get public class Person { public string Name { get; set; } } And if not for this, why would I else

T4 Template containing XML results in parse errors

旧巷老猫 提交于 2020-01-02 05:37:06
问题 I have created T4 Templates for the config files of my web and windows projects. I can successfully generate master web.config, and all configs for other environments, i.e. web.ci.config, etc..However, I could not get rid of the errors on my master tt files, such as : Character '#', hexadecimal value 0x23 is illegal in an XML name. Character '<', hexadecimal value 0x3c is illegal in XML attribute values. Unexpected XML declaration. The XML declaration must be the first node in the document

T4 append output to existing file

折月煮酒 提交于 2020-01-02 00:57:08
问题 Is it possible to make a T4 template output to be merged with an existing file? For example, if a T4 template generates localization resource XML files, is it possible to merge them in some existing resource file? 回答1: You can get access to the underlying string builder the the T4 uses thought the GenerationEnvironment property. So by adding something like the following to your T4 you should be able to get a workable solution; <#@ template debug="false" hostspecific="false" language="C#" #> <

How to deploy T4 include files with NuGet packages

旧城冷巷雨未停 提交于 2020-01-01 12:16:09
问题 I have some T4 include files which I want to reuse in several projects. So I have created a NuGet package and placed the files in the Tools folder of the package. Now they are installed in the packages\PackageName.x.x.x\Tools folder and I can add an include directive in my T4 files in the project. But the disadvantage of this is, that there is a version number in the path which will change when I create new versions of the package. That would require me to update all include directives in the

How to use T4 to generate two files at the same time from one template?

混江龙づ霸主 提交于 2020-01-01 04:22:12
问题 I am having a case in which I need to generate two CSharp code files with pretty the same code but different namespace of the input and output types of the methods. In fact each file is for a specific country and the types come from country specific WSDL's. I am writing some wrappers around the services and the logic is exactly the same but the types automatically generated from WSDL's are different. How could I reduce the coding effort and write the logic at one place and get it generated

Generating F# code

谁说胖子不能爱 提交于 2020-01-01 03:11:17
问题 T4 is the "official" code generation engine for C#/VB.NET. But F# doesn't support it (this is from April, but I couldn't find any newer mentions). So what is a good way to generate F# code? EDIT: I want to implement 2-3 finger trees in F#. I already have implemented them in C#, so this should be a nice comparison. The "digits" and nodes of the tree can be represented as arrays, so type 't FingerTree = Empty | Single of 't | Deep of 't array * (('t FingerTree) array) lazy * 't array However,

Is there code generation API for TypeScript?

旧城冷巷雨未停 提交于 2020-01-01 02:07:26
问题 When I needed to generate some C# code, for example DTO classes from xsd schema, or an excel table, I've used some roslyn API's. Is there something simmilar for typescript? 回答1: as of Oct-2018 You could use standard TypeScript API for that import ts = require("typescript"); function makeFactorialFunction() { const functionName = ts.createIdentifier("factorial"); const paramName = ts.createIdentifier("n"); const parameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined,

Retrieving fluent configuration programmatically without instantiating DbContext

家住魔仙堡 提交于 2019-12-31 03:38:08
问题 I have a DbContext derived class whose member entity classes are configured using Fluent API. I want to retrieve these configurations and relationships programmatically. 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

Code generation: Custom controller templates

旧时模样 提交于 2019-12-30 06:14:09
问题 To start off, I'm using Asp.Net MVC 4, and I've modified my solution to contain the CodeTemplates folder by following this tutorial. (I think my issue might be MVC related?) I've replaced the code in the Ajax grid template with a with my own JQgrid-template, which was fine for getting my project started. But I'm having trouble creating completely new controller templates (well the having them show up in the create new controller menu) any ideas? Update I've taken a few stabs at using the

Where can I find the API specification for MvcTextTemplateHost?

旧街凉风 提交于 2019-12-30 04:40:27
问题 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