code-generation

Does IntelliJ IDEA have a Create Wrapper code generator

邮差的信 提交于 2019-12-22 03:21:32
问题 If I have an interface with a few methods. Sometimes I need to create a new implementation of the interface which wraps another instance of the interface and delegates most of the methods to the wrapped instance. Then I would change a couple of the implementations, maybe not delegating them. A classic example would be the Collections.unmodifiableXXX() methods in the JDK which block access to the modification methods. Does IntelliJ have any code assistance that will generate a delegate

Can I generate an async method dynamically using System.Linq.Expressions?

南笙酒味 提交于 2019-12-22 01:28:11
问题 I know the compiler can't convert an async lambda expression to an expression tree, but is it possible to generate the expression tree manually ? var expr = Expression.Lambda<Func<Task>>( // how do I use 'await' in the body here? ); var func = expr.Compile(); I can't find any method related to async or await in the Expression class, but perhaps there's another way? 回答1: await involves significant compiler re-writing; the generated IL is quite dissimilar to the original C#, with variable

Is there any way to have functions in basic T4 templates?

北城余情 提交于 2019-12-22 01:12:41
问题 By basic T4 template, I mean not using T4 Toolkit or any of the add-ins. My T4 is getting a little complicated, but I'd like to keep in self-contained for now. Is there a way have functions in your T4 template, without referencing external assemblies? 回答1: You mean like this: <#+ public List<string> Dostuff() { List<string> result = new List<string>(); // ... return result; } #> Here's a complete example: Reading a Xml File in T4 Templates Oleg Sych's T4Toolbox is a good resource. 来源: https:/

How can I create an ObjectContext from separate ssdl + csdl + msl files and no edmx?

三世轮回 提交于 2019-12-21 23:06:04
问题 Given: An empty C# project 3 loose files: an SSDL, CSDL and a MSL (generated elsewhere) No EDMX file What modifications/additions should I perform on project to compile these files into a T4-based ObjectContext (e.g. using POCOs T4 generators)... if I already have all classes generated for entities? if I have no classes generated for entities? Would it be easier to generate the ObjectContext and or classes if I first combine the files into an EDMX with no Designer section? 回答1: Working

How to write my XSD in order to match the desired XML and Java format using JAXB and XJC [duplicate]

老子叫甜甜 提交于 2019-12-21 22:17:22
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How generate XMLElementWrapper annotation with xjc and customized binding I would like to be able to process XML of this format using JAXB ... <configuration> <!-- more content here --> <things> <thing> <name>xx1</name> <value>yy1</value> </thing> <thing> <name>xx2</name> <value>yy2</value> </thing> </things> <!-- more content here --> </configuration> I'd like to marshal the above XML into these Java classes

How can I generate multiple classes from xsd's with common includes?

岁酱吖の 提交于 2019-12-21 20:59:19
问题 Aloha I received a few nice xsd files which I want to convert to classes (using xsd.exe) All the xsd's have the same includes, like this: <xs:include schemaLocation="kstypes.xsd" /> <xs:include schemaLocation="ksparams.xsd" /> When I generate a class for each xsd the types declared in these files are duplicated for each original xsd. Is there any easy way to 1) only generate the types in the included xsd's once and 2) make sure all other classes use these types? -Edoode 回答1: try the approach

In a SIGILL handler, how can I skip the offending instruction?

对着背影说爱祢 提交于 2019-12-21 20:05:20
问题 I'm going JIT code generation, and I want to insert invalid opcodes into the stream in order to perform some meta-debugging. Everything is fine and good until it hits the instruction, at which point the thing goes into an infinite loop of illegal instruction to signal handler and back. Is there any way I can set the thing to simply skip the bad instruction? 回答1: It's very hacky and UNPORTABLE but: void sighandler (int signo, siginfo_t si, void *data) { ucontext_t *uc = (ucontext_t *)data; int

In a SIGILL handler, how can I skip the offending instruction?

我们两清 提交于 2019-12-21 20:01:06
问题 I'm going JIT code generation, and I want to insert invalid opcodes into the stream in order to perform some meta-debugging. Everything is fine and good until it hits the instruction, at which point the thing goes into an infinite loop of illegal instruction to signal handler and back. Is there any way I can set the thing to simply skip the bad instruction? 回答1: It's very hacky and UNPORTABLE but: void sighandler (int signo, siginfo_t si, void *data) { ucontext_t *uc = (ucontext_t *)data; int

How to use Brail as a stand-alone general purpose templating engine (like NVelocity)?

最后都变了- 提交于 2019-12-21 19:45:16
问题 I've been using NVelocity as a stand-alone templating engine in my text file generator. The problem with NVelocity is that the macros are quite shaky; pretty much all errors I get are from faulty macro implementation. It would be cool if I could just use some other templating engine, such as Brail. That way I would just write functions that output strings. What's the best way of embedding Brail engine? I would like to just pass it a string containing the template (not reading from disk), and

T4 vs CodeDom vs Oslo [closed]

喜欢而已 提交于 2019-12-21 17:32:53
问题 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 . In an application scaffolding project on which I'm working, I'm trying to decide whether to use Oslo, T4 or CodeDom for generating