DebuggerTypeProxy for IronPython Old-style Class and Instance

First I want to make it clear that this post means nothing related to IronPython’s plan about debugging python code in the future; it serves more as an interesting example to demonstrate DebuggerTypeProxyAttribute and how types can be created dynamically and be used in the VS debugger windows to display information the end users are…

1

Always Peverify IL Code of your Dynamic Method

Current dynamic method implementation does not have built-in support to pre-check whether the dynamic method code is verifiable. With bad IL sequence, very often you will get “System.InvalidProgramException: Common Language Runtime detected an invalid program” when it gets executed. See the code example below, where C1, C2 are 2 simple reference types. Btw I understand…

0

ILGenerator.EmitCall Mainly For vararg Methods

Vararg (variable arguments) methods accept argument lists of unknown length and type. CLR supports this by the IL instruction (arglist) and other BCL types, such as System.ArgIterator. C# compiler has undocumented keyword “__arglist” to support defining vararg methods, accessing variable arguments and calling them, as shown below. static void VarargMethod(string headline, __arglist) {  ArgIterator ai…

0

Reflection.Emit and Resources

Reflection.Emit is relatively new to me. Recently I had a chance to deal with a resource related emit issue and had a tough time wading through so many emit APIs with “resource” in their names. Seems they are kind of messy, and I feel the API naming is not as good as it can be….

2

Activator.CreateInstance and beyond

Q: Assume we have 2000 unknown types; (however) we know each type has a constructor with integer as its’ only parameter type. How to create objects 10000 times for each type (and make such late-new fast)? Activator.CreateInstance comes to my fingers first. It is just so convenient to use: calling Activator.CreateInstance(type, new object[] {100}) in…

12