code-generation

Programmatically implementing an interface that combines some instances of the same interface in various specified ways

大兔子大兔子 提交于 2019-12-07 14:26:47
问题 What is the best way to implement an interface that combines some instances of the same interface in various specified ways? I need to do this for multiple interfaces and I want to minimize the boilerplate and still achieve good efficiency, because I need this for a critical production system. Here is a sketch of the problem. Abstractly, I have a generic combiner class which takes the instances and specify the various combinators: class Combiner<I> { I[] instances; <T> T combineSomeWay

Code template implementation with C#

大城市里の小女人 提交于 2019-12-07 14:19:50
问题 When I need code template, I can use Python as follows. templateString = """ %s %s %s """ print templateString % ("a","b","c") How do I implement the equivalent with C#? I tried using System; class DoFile { static void Main(string[] args) { string templateString = " {0} {1} {2} "; Console.WriteLine(templateString, "a", "b", "c"); } } But I got dogen.cs(86,0): error CS1010: Newline in constant dogen.cs(87,0): error CS1010: Newline in constant dogen.cs(88,0): error CS1010: Newline in constant

What are GCC's passes and invoked programs?

假如想象 提交于 2019-12-07 11:07:20
问题 It came up in another question: What are the programs and parts called by gcc (particularly when compiling C or C++ ) so that someone might engineer some scheme of intercepting and altering the flow for various custom coding purposes? 回答1: The compiler binaries are the "compiler driver" (i.e. gcc ), and the compiler itself which also doubles as a preprocessor ( cc1 or cc1plus ). It also invokes the assembler ( as ), and the linker ( ld ). Additionally there's a tool called collect2 that

How can I get details about a Silverlight code generation exception?

余生长醉 提交于 2019-12-07 09:04:35
问题 I'm getting the following error now when I build my Silverlight Business Application: The code generator 'Microsoft.ServiceModel.DomainServices.Tools.CSharpCodeDomClientCodeGenerator' encountered a fatal exception and could not generate code for project 'C:\Software\ProjectPartCenterAdmin\Alpha\Latest Version\ProjectPartCenterAdmin\ProjectPartCenterAdmin.csproj': Exception has been thrown by the target of an invocation. I DID ABSOLUTELY NOTHING TO MY CODE since it last worked! All I did was a

Java code generation

筅森魡賤 提交于 2019-12-07 08:12:36
问题 I am looking for nice (java) code generation engine. I have found cglib but it is very poorly documented and I am not quite sure that it can generate actual java classes (files) and only dynamic classes. If I am wrong maybe someone knows has a link with an example. Roman 回答1: Have a look at codemodel, used with success for my projects. 回答2: Didn't really try, but you may want to take a look at another code generation Java framework called Javassist, which also has pretty thorough tutorial.

Using JET to generate code: Indenting code

心不动则不痛 提交于 2019-12-07 07:05:29
问题 I'm trying to do the following: Write a JET template that receives an object of type Class as argument. The object should represent a Java interface. The template generates a class that implements the interface, i.e. provides methods for all the method signatures it defines. The name of the generated class should be XImplementation where X is the name of the argument interface. The methods in the generated class do nothing or only return constant values: 0 for int and double, false for

How to run TextTransform.exe from VS 2015 on PC without Visual Studio installed?

雨燕双飞 提交于 2019-12-07 05:30:24
问题 I copied TextTransform.exe from PC with VS 2015 Update 3 installed from location C:\Program Files (x86)\Common Files\Microsoft Shared\TextTemplating\14.0\TextTransform.exe to PC without VS 2015 installed. TextTransform.exe is called as a part of build scripts. When I run it I get following error: Error: Exception has been thrown by the target of an invocation. I read the article Code Generation in a Build Process. I tried to copy all dll-s described in section "Configure your machines". But I

Is there a tool to generate XML picklers in Haskell from an XSD?

只谈情不闲聊 提交于 2019-12-07 05:15:26
问题 I'd like to generate XML picklers for an XSD file. It seems like a useful tool that might already exist. Does it? 回答1: HaXml does have a tool for generating Haskell data types from DTDs and a tool for generating Haskell data types from XSDs: http://hackage.haskell.org/package/HaXml The executables are named XsdToHaskell and DtdToHaskell. If you're on Windows and you have PATH modified by Haskell Platform, you'll need to call it like this: xsdtohaskell < path_to.xsd > path_to.hs The generated

Time to develop an option in Eclipse to modify a Java file source

試著忘記壹切 提交于 2019-12-07 04:24:55
问题 I'm evaluating the possibility of developing an Eclipse plugin to modify the source code of some Java files. The Eclipse plugin should: add one menu option or context menu option to launch the modification process. add a key binding only alter the UI in that way when an editor has been open on a Java file. the modification process would not open a dialog, or maybe, a very simple one. the modification process would traverse the AST of the Java file and would modify it. Considering that we have

T4 Preprocessed Template Debugging Not Working - Visual Studio 2010 RTM

折月煮酒 提交于 2019-12-06 23:07:10
问题 I am attempting to debug a preprocessed T4 template and I am not able to step into the class created by running the preprocessed template. I am able to create an instance of the class but as soon as I try to step into while debugging, a new window pops up that says No source available. There is no source code available for the current location. My understanding was that preprocessed templates could be debugged just like a normal c# class, is this not correct? Is there anything in particular