code-generation

Tool to generate interface implementation by delegation?

删除回忆录丶 提交于 2019-12-06 11:24:49
问题 I often need to implement an interface by delegating the implementation to a member of my class. This task is quite tedious because, even though Visual Studio generates stubs for the interface methods, I still have to write the code to delegate the implementation. It doesn't require much thinking, so it could probably be automated by a code generation tool... I'm probably not the first one to think of this, so there must be such a tool already, but I couldn't find anything on Google... Any

How to convert a json to a typescript interface?

杀马特。学长 韩版系。学妹 提交于 2019-12-06 11:07:15
Given a JSON output of an api: { "id": 13, "name": "horst", "cars": [{ "brand": "VW", "maxSpeed": 120, "isWastingGazoline": true, }] } I would like to define interfaces for typescript: export interface Car { brand: string; maxSpeed: number; isWastingGazoline: boolean; } export interface RaceCarDriver { id: number; name: string; cars: Car[]; } Yet I don't want them to type them manually, I rather have a script generate them for me. How can I convert json into typescript interfaces? I also don't want to use webservices like json2ts . You can write the script using typescript compiler API and its

T4 Output to String

感情迁移 提交于 2019-12-06 11:00:50
I am new to T4, I want to generate CRUD Stored Procedures, Data access layer, output to string, I am trying to create kind of webservice api to be useful to other programmers also, just input the data, and download zip file. I have searched a lot but could not find a way to generate output to string, is it possible, any articles, links, a bit of code if possible would be helpful. Yes, we can also use StringBuilder, but The question is "T4 Output to String" please all type of answers are welcome, but try to focus on the question. You can use preprocessed T4 templates to return a string instead

Can EF4 generate POCO for me, or do I have to write them myself?

断了今生、忘了曾经 提交于 2019-12-06 09:57:14
问题 I've been playing about with the Entity 4 framework lately and it's pretty nifty. I've setup a class called Customer.cs with some properties like Name, Address etc. I also have a class called StoreEntities.cs which binds these back to the database through DbSet. It works fine and I can pull all my customers from the database. The problem is every tutorial I come across on the internet generates their classes by hand. What I mean is, they all say something like "Now I'm going to make a new

Caching generated classes in Byte Buddy?

随声附和 提交于 2019-12-06 09:01:21
问题 I have been using CGLIB's Enhancer for a while, but considering to switch over to Byte Buddy. It's pretty basic stuff, proxy for up to a few hundred data access interfaces, created on demand. Enhancer enhancer = new Enhancer(); enhancer.setClassLoader(...); enhancer.setSuperclass(...); enhancer.setInterfaces(...); enhancer.setCallback(...); enhancer.create(); CGLIB is caching the generated type to improve performance. What is the recommended approach with Byte Buddy? I want to avoid any

AndroidAnnotations and Unit Testing

扶醉桌前 提交于 2019-12-06 08:17:55
问题 I am using AndroidAnnotations(2.5) in a sample project I am currently working on. Since you can annotate your classes with for example @EActivity , @ViewById , @Click which will all lead to generated compile-time code, I was wondering how one would go about creating unit tests / functional tests for any Android Annotations powered application. I would love to hear some opinions on this matter. Cheers, 回答1: I responded to a similar post here. There are a couple of options available to you. You

CompileAssemblyFromDom throws access denied exception

不问归期 提交于 2019-12-06 08:02:33
问题 The code: using (var codeProvider = new CSharpCodeProvider()) { var compilerParameter = new CompilerParameters( _assemblies, assemblyName, false) { GenerateInMemory = true, CompilerOptions = "/optimize" }; var compilerResults = codeProvider.CompileAssemblyFromDom( compilerParameter, templateResults.Select(r => r.GeneratedCode) .ToArray()); } It throws exception: CS1567 Error generating Win32 resource: Access is denied. What does it mean? 回答1: I get this working. The problem was that

How to get String.Format not to parse {0}

岁酱吖の 提交于 2019-12-06 07:59:09
I am writing a code generation tool that frequently will have lines like StringBuilder sp = new Stringbuilder(); sp.AppendFormat(" public {0}TextColumn()\n", className); sp.AppendLine(" {" sp.AppendLine(" Column = new DataGridViewTextBoxColumn();"); sp.AppendFormat(" Column.DataPropertyName = \"{0}\";\n", columnName); However the issue I am having is when I run in to a line like this. sp.AppendFormat("return String.Format(\"{0} = '{0}'\", cmbList.SelectedValue);", columnName); I want the first {0} to turn in to whatever the value of columnName is but I want the seccond {0} to be left alone so

drools programmatically generate a fact model

痴心易碎 提交于 2019-12-06 07:49:39
I need to generate an enormous fact model using an ontology external to drools. Now, I could certainly write a script/program to pull this off. My approach would be to generate a java bean for each ontology class which contains the appropriate fields, methods, and references to other java objects based on ontological relationships (probably in a map). My question is whether drools has a more elegant way to approach this problem. I figure it must be a common problem that the fact model is derivable from resource available outside of drools, so I'm wondering if maybe drools(or guvnor) has a

Is there a Perl script to implement C++ Class get/set member functions?

℡╲_俬逩灬. 提交于 2019-12-06 07:28:15
问题 I was reading this morning the book The Pragmatic Programmer Chapter 3 on Basic Tools every programmer should have and they mentioned Code Generation Tools. They mentioned one Perl script for C++ programs which helped automate the process of implementing the get/set() member functions for private data members. Does anyone know about such a script and where to find it? I've been unable to come up with the right google keywords to find it. 回答1: Although it doesn't directly answer your question,