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
37
votes
3 answers
Formatting Literal parameters of a C# code snippet
Is there any way that I can change how a Literal of a code snippet renders when it is used in the code that the snippet generates?
Specifically I'd like to know if I can have a literal called say, $PropertyName$ and then get the snippet engine to…

Michael Lang
- 2,157
- 3
- 22
- 29
37
votes
9 answers
Dynamically generate classes at runtime in php?
Here's what I want to do:
$clsName = substr(md5(rand()),0,10); //generate a random name
$cls = new $clsName(); //create a new instance
function __autoload($class_name)
{
//define that instance dynamically
}
Obviously this isn't what I'm actually…

Will Shaver
- 12,471
- 5
- 49
- 64
36
votes
7 answers
Best Python templating library to facilitate code generation
Instead of me spending the next day (or year) reading about them all, are there any suggestions for templating engines that I should look into in more detail?

taudep
- 2,871
- 5
- 27
- 36
36
votes
4 answers
35
votes
4 answers
Generating DLL assembly dynamically at run time
Currently I have some code that is being generated dynamically. In other words, a C# .cs file is created dynamically by the program, and the intention is to include this C# file in another project.
The challenge is that I would like to generate a…

7wp
- 12,505
- 20
- 77
- 103
35
votes
5 answers
How to view "generated HTML code" in Firefox?
If using Firebug, we can click on the HTML tab, and click to expand each element to see the generated HTML code. Is there a way to expand it all or get a plain text file?
I just accidentally found out that there doesn't even need to be Firebug. We…

nonopolarity
- 146,324
- 131
- 460
- 740
35
votes
4 answers
How to hide files generated by custom tool in Visual Studio
I would like the files generated by my custom tool to be hidden, but I cannot find any documentation on how this is done.
An example of what I'm looking for is WPF code behind files. These files are not displayed in the Visual Studio project view,…

jaws
- 1,952
- 4
- 20
- 27
35
votes
6 answers
Why does Visual Studio use xchg ax,ax
I was looking through the disassmbly of my program (because it crashed), and noticed lots of
xchg ax, ax
I googled it and found out it's essentially a nop, but why does visual studio do an xchg instead of a noop?
The application is a C# .NET3.5…

Malfist
- 31,179
- 61
- 182
- 269
35
votes
8 answers
How can I automatically add some skeleton code when creating a new file with vim
When creating a new file with vim, I would like to automatically add some skeleton code.
For example, when creating a new xml file, I would like to add the first line:
Or when creating an html file, I would like to…

The Great Wuga Wuga
- 353
- 1
- 3
- 5
34
votes
8 answers
XML Schema to C++ Classes
I have to write a C++ Application (using the Qt Framework for the GUI) that can edit data stored in xml files described by a xsd schema file. Is there a tool to convert the xsd schema into C++ Classes?

Andre
- 3,223
- 4
- 23
- 19
34
votes
3 answers
Lombok Maven javadoc:aggregate report with generated sources
I have a multimodule java project built with Maven to which I want to generate javadocs with javadoc:aggregate. The project structure looks like:
parent
├─lomboklib
└─other
I am also using Project Lombok to generate some methods in the project. I…

Eero Aaltonen
- 4,239
- 1
- 29
- 41
33
votes
3 answers
Is it possible to programmatically compile java source code in memory only?
I have found many references explaining how to programmatically compile a Java class using the JavaCompiler class:
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
int result = compiler.run(null, null, null, "a_file_name");
However, I…

Sergio
- 8,532
- 11
- 52
- 94
33
votes
5 answers
Given a type instance, how to get generic type name in C#?
Given a generic type, including
List
Nullable
How do I get a generic name for C#?
var t = typeof(Nullable);
var s = t.GetGenericTypeDefinition().Name + "<" + t.GetGenericArguments()[0].Name + ">";
This yields…

George Polevoy
- 7,450
- 3
- 36
- 61
33
votes
2 answers
shortcut to add throws declaration in Intellij Idea
I am using eclipse for quite a while, but for last year or so I am trying to get used to Intellij Idea because that is what they use at my current workplace.
One feature I can not find a substitute in Idea is ability of eclipse to add throws…

J.J
- 633
- 1
- 6
- 14
32
votes
8 answers
Code generation by genetic algorithms
Evolutionary programming seems to be a great way to solve many optimization problems. The idea is very easy and the implementation does not make problems.
I was wondering if there is any way to evolutionarily create a program in ruby/python script…

dfens
- 5,413
- 4
- 35
- 50