Topics related to the generation of code as the output of an application, instead of directly writing code by a programmer.
Questions tagged [code-generation]
3642 questions
20
votes
1 answer
Controlling symbol generation in Clojure macros
I'm trying (as a self-learning exercise) to create a Clojure macro that will generate code to apply a function to a sequence of integers and sum the result, e.g.
f(0) + f(1) + f(2) + f(3)
This is my attempt:
(defmacro testsum [func n]
`(fn [x#]…

mikera
- 105,238
- 25
- 256
- 415
20
votes
5 answers
What is the utility of the attribute GeneratedCodeAttribute in C #?
I generated some of my C# code with an external tool. Each generated class has an attribute GeneratedCodeAttribute. Why is my generator creating this attribute?

Bastien Vandamme
- 17,659
- 30
- 118
- 200
20
votes
1 answer
Generation of documentation comments in AppCode 3.0 like in IntelliJ
Is there any way in AppCode 3.0 to generate documentation comments like in IntelliJ?
For example, in IntelliJ I can type a method:
public int method(float number){
// magic
}
And when above it, I will type: /**, IDE will generate me code like…

Apan
- 1,027
- 2
- 10
- 27
20
votes
4 answers
Generating pass-through code when "preferring composition over inheritance"
Problem
Let's say I'm trying to model a cell phone as a combination of a regular phone and a PDA. It's sort of a multiple inheritance scenario (a cell phone is a phone, and it is a PDA). Since C# doesn't support multiple inheritance, this pretty…

devuxer
- 41,681
- 47
- 180
- 292
20
votes
4 answers
How can I automatically add existing items to a Visual Studio project?
I have a tool which dynamically generates .xaml and .xaml.cs files and puts them in the appropriate Visual Studio directory.
To add them to the project, I have to then:
right-click on that directory
choose "add existing item"
navigate to the…

Edward Tanguay
- 189,012
- 314
- 712
- 1,047
20
votes
4 answers
Generate and publish Ruby based REST APIs documentation
What are cool kids using nowadays to easily parse/generate/publish REST APIs? I took a look on Swagger and It looks nice but from my point of view it doesn't fit ok with Ruby. Maybe I'm just wrong and I'm missing something, help would be…

jpemberthy
- 7,473
- 8
- 44
- 52
19
votes
2 answers
Is there a way to put the generated files in a separate folder in flutter?
In my app, I use freezed with json_serializable. In the folder, where I put all my data models a lot of generated files, like model.g.dart, model.freeezed.dart. Is there any possibility to move all generated files like that to a separate folder in…

Денис Тараненко
- 341
- 2
- 10
19
votes
2 answers
Testing a Code-Generator Optimization
I have written a low-level optimization for the LLVM code-generator backend. Basically, the optimization will reorder assembly instructions at the basic block level to allow a later (existing) optimization to more efficiently optimize the resultant…

Zeke
- 1,974
- 18
- 33
19
votes
2 answers
How to install svcutil.exe under Windows 10
I am desperately searching for a way to install svcutil.exe because I read here and elsewhere that this was the way to compile a WSDL into C# code. I tried it via Windows SDK install, which yielded a folder of about 1K installers of whom I don't…

Daniel Hiller
- 3,415
- 3
- 23
- 33
19
votes
2 answers
What are the limits to code generation from XML Schema in C#?
I've seen several questions regarding problems with generating classes from XML Schema using xsd.exe, along with suggestions for how to pre-process the schema (often using XSLT) to resolve some of the trickier aspects prior to generation. My…

James Walford
- 2,953
- 1
- 24
- 37
19
votes
2 answers
Visual Studio 2015 not automatically adding asterisk for multiline comments
When typing multi-line comments Visual studio used to add an automatic asterisk to each new line of the comment as I press enter(apparently 2015 does not do this anymore). I really liked this. As of right now though, if I type "/*" and enter, Visual…

Krythic
- 4,184
- 5
- 26
- 67
19
votes
2 answers
Can I generate an async method dynamically using System.Linq.Expressions?
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>(
// how do I use 'await' in the body here?
);
var func =…

Thomas Levesque
- 286,951
- 70
- 623
- 758
19
votes
8 answers
Can I automatically generate controller classes from FXML?
As I understand it, when using FXML to describe a Java FX scene, the controller class is written manually and it's member variables and methods can then be referenced from the .fxml file. When loading the scene using the FXMLLoader, member variables…

Feuermurmel
- 9,490
- 10
- 60
- 90
19
votes
5 answers
What are the best resources for learning CIL (MSIL)
I'm an expert C# 3 / .NET 3.5 programmer looking to start doing some runtime codegen using System.Reflection.Emit.DynamicMethod. I'd love to move up to the next level by becoming intimately familiar with IL.
Any pointers (pun intended)?

TheSoftwareJedi
- 34,421
- 21
- 109
- 151
18
votes
7 answers
How can I extend Java code generated by JAXB, CXF or Hibernate tools?
With generated Java source code, like
code generated with Hibernate tools
code generated with JAXB schema binding (xjc)
code generated with WDSL2Java (cxf)
all generated classes are "value object" types, without business logic. And if I add…

mjn
- 36,362
- 28
- 176
- 378