Questions tagged [dynamic-code]
36 questions
19
votes
1 answer
How to highlight dynamic code in visual studio
Is it possible and if so how, to make Visual Studio highlight dynamic expressions in code?
When I just hovered above some code, visual studio told me it was a dynamic expression. This made me realize I made a mistake in my code and used one dynamic…

Patrick Huizinga
- 1,342
- 11
- 25
7
votes
3 answers
Loading multiple versions of the same class
Let's say I release a code library as a standalone PHP class. Someone then uses version 1.0 of that library in their application. Later, I release version 2.0 of the library and that same someone, for any reason, needs to use both 1.0 and 2.0…

EAMann
- 4,128
- 2
- 29
- 48
7
votes
3 answers
How to initialize various type variables in dynamically generated C# code?
I have T4 template where I'd like to generate an .cs file.
I have an array of System.Data.DataColumn that i'd like to use as a private variables in my generated code file.
I'm using ColumnName as variable name, Value as variable value and DataType…

Sergejs
- 2,540
- 6
- 32
- 51
6
votes
4 answers
Java Dynamic Code Generation with support for generics
Is there any tool which provides Java dynamic code generation and that also supports generics?
Javassist for example, is the kind of tool that I need, but it does not support generics.
I wrote a small lib which uses the Java 6 Compiler API, however…

halfwarp
- 1,780
- 5
- 24
- 41
5
votes
3 answers
In how many ways can methods be added to a ruby object?
When it comes to run time introspection and dynamic code generation I don't think ruby has any rivals except possibly for some lisp dialects. The other day I was doing some code exercise to explore ruby's dynamic facilities and I started to wonder…

David K.
- 6,153
- 10
- 47
- 78
5
votes
4 answers
Place an object on top of stack in ILGenerator
I have to pass a function an instance of an object, so obviously all the information to be taken as argument is to be loaded onto the evaluation stack
Here is the code that i am looking for
someClass SomeObject = new…

Basit Anwer
- 6,742
- 7
- 45
- 88
4
votes
0 answers
Problems with PDB file through CodeDom
I have been creating a plugin model where code will be written on the server and a dll output will be created and downloaded to the client side.
This works well, but as we also want to have debugging support for the code that is generated in…

abhishek
- 2,975
- 23
- 38
4
votes
2 answers
Add/Generate Methods at Compile Time
I am currently building an API that I will be asking a number of developers to use. Most of it is straightforward, but there are a couple of api calls that are complex in nature, but should be used in pretty much a boilerplate way.
What I would like…

Codemwnci
- 54,176
- 10
- 96
- 129
3
votes
2 answers
Are there possible security concerns with exposing system.dll via web service?
I'm curious what damage someone could do with just access to the System.dll namespace in C#.
I was playing around with dynamic code compiling and created a simple website which allows me to type in C# code. This is passed via web service to a class…

Andrew Grothe
- 2,562
- 1
- 32
- 48
3
votes
3 answers
Workflow like system to change code flow
I need advice regarding a requirement in one of our project. What we are trying to achieve is that we want to control flow of methods calls from a text or XML file.
For example:
string response = new Assembly1.Class1().DoStuff();
if (response ==…

Naveed
- 75
- 5
3
votes
3 answers
C# Dynamic Type Initializer
I'm trying to build something like the C# type initalizer dynamically:
MyClass class = new MyClass { MyStringProperty= inputString };
I want to build a generic method that reflects over a given type once and returns a delegate which creates a new…

Paul
- 6,188
- 1
- 41
- 63
3
votes
1 answer
Convert string to c# executable code
I have a small solution, I did a research on this topic but couldn't find exactly what i am looking for, the examples was either to compile a whole method in a string or a full expression. What i want is say i have this code which i am trying to…

Hasitha Shan
- 2,900
- 6
- 42
- 83
2
votes
0 answers
Is it possible to dynamically generate bytecode that is executed inside the LLVM started by lli?
I am currently evaluating possible tools to generate machine code ahead-of-time and dynamically for a toy compiler project.
The compiler should be able to translate the source code into a runnable byte code so that code can be added later…

Marc
- 4,327
- 4
- 30
- 46
2
votes
0 answers
Dynamic C code execution: memory references
tl;dr : I'm trying to execute dynamically some code from another snippet. But I am stuck with handling memory reference (e.g. mov 40200b, %rdi): can I patch my code or the snippet running code so that 0x40200b is resolved correctly (as the offset…

Maxime B.
- 1,116
- 8
- 21
2
votes
1 answer
Options for dynamic code generation
I have a (hypothetical) question and I think the solution would be to dynamically generate code.
I want to quickly evaluate an arbitrary mathematical function that a user has entered, say to find the sum i=1 to N of i^3+2i^2+6i+1. N is arbitrary…

Bernard
- 5,209
- 1
- 34
- 64