code-generation

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#" #> <

Generate exe in .Net

孤街醉人 提交于 2020-01-01 19:30:08
问题 In .Net, you can generate byte code in memory, and presumably save the resulting program to a .exe file. To do the first step, I have the following test code adapted from http://www.code-magazine.com/Article.aspx?quickid=0301051 var name = new AssemblyName(); name.Name = "MyAssembly"; var ad = Thread.GetDomain(); var ab = ad.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run); var mb = ab.DefineDynamicModule("MyModule"); var theClass = mb.DefineType("MathOps", TypeAttributes.Public); var

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

C# Code Generation

自作多情 提交于 2020-01-01 03:21:18
问题 I am looking at creating a small class generator for a project. I have been reading about CodeDOM so it the semantics of creating the classes does not appear to be an issue, but am unsure oh how to best integrate the generation into the development and deployment process. How should I trigger the creation of the classes? I have read it should be part of the build process, how should I do this? Where should the classes be created? I read that the files should not be edited by hand, and never

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,

Is there a Coffeescript for Java? In other words X gets compiled to Java [closed]

两盒软妹~` 提交于 2020-01-01 01:30:50
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . Is there a language that gets compiled to Java code (not Byte code but Java .. so no Groovy, Scala, Jython, JRuby etc.)? In other words is there a CoffeeScript for Java? One of the major flaws I have against Java is that its so damn verbose and that it doesn't have multiple inheritance. It seems reasonably that

Simple CRUD Generator for C# [closed]

一笑奈何 提交于 2019-12-31 15:50:41
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am looking for a simple CRUD (or DAL) Generator for C#. I don't want anything heavyweight since I only have a couple of tables in a

Visually distinguish auto-generated files?

别等时光非礼了梦想. 提交于 2019-12-31 04:03:31
问题 We have a bunch of files that are auto-generated based on the database model. I have had some facepalm experiences because I modified some code, only to find out my modifications where overwritten because I'd not noticed that my changes were in those generated files. So, I modified our generator to include a "do not modify" comment in the file header. This helps! Although, when tracing method calls, it's easy to end up in the middle of one of these files, and you wouldn't necessarily know

Visually distinguish auto-generated files?

≡放荡痞女 提交于 2019-12-31 04:03:24
问题 We have a bunch of files that are auto-generated based on the database model. I have had some facepalm experiences because I modified some code, only to find out my modifications where overwritten because I'd not noticed that my changes were in those generated files. So, I modified our generator to include a "do not modify" comment in the file header. This helps! Although, when tracing method calls, it's easy to end up in the middle of one of these files, and you wouldn't necessarily know