ilgenerator

Is there a good wrapper around ILGenerator ?

I'm using System.Reflection.Emit for a while now, and find it (who don't?) as painful as bug prone. Do you know if there is a good wrapper around the IL Generator, something that I can rely on to emit IL in a more safe and easier manner than with playing directly with SRE? Edit: I know that manipulating expression trees is definitivel...

Are there any gotchas or good reasons not to use autosproc for stored procedure calls?

I've implemented a data access layer that populates generic entities from a datareader using a variation of the third monkey approach (http://www.codeproject.com/KB/database/DynamicMethod_ILGenerator.aspx). This works well, performs well and saves me writing loads of repetetive code for data retrieval. Now I want to add methods that tak...

Dynamic event generation in C# using DynamicMethod and ILGenerator

I need to generate an event handler based on an EventInfo object in runtime and call a method within that event handler. Something like the following: public void RegisterAction(ActionData actionData, EventInfo eventInfo, Control control) { MethodInfo methodInfo = eventInfo.EventHandlerType.GetMethod("Invoke"); List<Type> ...

Dynamic object property populator (without reflection)

I want to populate an object's properties without using reflection in a manner similar to the DynamicBuilder on CodeProject. The CodeProject example is tailored for populating entities using a DataReader or DataRecord. I use this in several DALs to good effect. Now I want to modify it to use a dictionary or other data agnostic object so ...

Convert C# code

Hi, I need to simulate in C# code (with ilGenerator.Emit) the following function public void AssignAttribute(ref ValueHolder output, Assignment assignment) { ResultAttribute attribute = null; if ( (attribute = output.MultipleResults.Find(delegate(ResultAttribute o) { return o.Name == assignment.Name; })) != null) ...

Using Reflection.Emit to emit a "using (x) { ... }" block?

I'm trying to use Reflection.Emit in C# to emit a using (x) { ... } block. At the point I am in code, I need to take the current top of the stack, which is an object that implements IDisposable, store this away in a local variable, implement a using block on that variable, and then inside it add some more code (I can deal with that last...

Why is it necessary to load every argument onto the stack in CIL method?

Hi, in my application I need to dynamically create a type that contains multiple properties. I am aware that in cases such as this, one has to generate an CIL for both getter and setter methods of a property by using an ILGenerator. More by a trial and error than anything else, I've finally arrived to the following code that generates ...