Member Order Returned by GetFields, GetMethods ...
As John mentioned in his post, every Reflection user should keep this in mind: our code should not count on the member order returned by GetFields, GetMethods and other similar GetXXXs calls. Given...
View ArticleILGenerator.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...
View ArticleShift Away from CLR Reflection Area
After 2-year Reflection test ownership and 1-year babysitting for Reflection.Emit and DynamicMethod areas, I am gradually away from these CLR feature areas, and will be more focusing on IronPython (and...
View ArticleAlways 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...
View ArticleSystem.Reflection-based ILReader
Compared to what I posted previously here (or what was used in the DynamicMethod visualizer), this new version introduced the Visitor pattern. A do-nothing visitor ILInstructionVisitor is included; the...
View ArticleTurn MethodInfo to DynamicMethod
I do not know why anyone ever need this :) but few readers did ask me similar questions before. Solving this problem also demonstrates one more ILReader usage. To build a DynamicMethod, we can choose...
View ArticleTake Two: IL Visualizer
I was glad to hear many positive feedbacks about the DebuggerVisualizer for DynamicMethod; on the sad side, it shows our lack of good LCG debugging support (on which, Mike Stall is seeking your...
View ArticleLate-bound Array SetValue
The type "System.Array" provides us a set of API for the late-bound array operations, including array creation (Array.CreateInstance), read/write access to array element...
View ArticleName of Array Type
Two things related to array type name came to my mind while writing the previous post. Given an one-dimensional non-zero based double array x, x.GetType().ToString() returns "System.Double[*]"; we can...
View ArticleDebuggerTypeProxy 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...
View ArticleIronPython: import clr
clr is an IronPython built-in module, which provides some functionalities in order to interop with .NET. When writing "import clr" in a python module, it means you intend to leverage the .NET...
View ArticleIronPython: clr.AddReference
In order to interop with .NET libraries, we need first load in the assemblies we want to play with. The family of AddReference methods in the clr module serves the purpose. clr.AddReference...
View ArticleIronPython: Grab the .NET Type
After loading the assembly by clr.AddReference and then import namespace, we are ready to take hold of types and down-level namespaces using "attribute references". >>> import...
View ArticleIronPython: Passing Arguments for a Call
After getting a CLR type, we can play it like a python type. We can get the class/static methods using the dot operator ("attribute reference") on the type, or create an instance of it and then get the...
View ArticleIronPython: Keyword Argument to Set .NET Property/Field
Use keyword arguments to set properties or fields… you likely ask the question: where can we do this? IronPython allows it in the constructor call, the call against the .NET type. Such keyword should...
View ArticleIronPython: Provide (or not) Argument for by-ref Parameter
Python function may return multiple objects as a tuple. The .NET method can only return one object as the result of a call; in order to return more than one objects, by-ref parameters are needed. They...
View ArticleIronPython: explicitly choose one method
C# allows method overloading. Given an argument list, the compiler performs the overload resolution to select the best method to invoke. The chosen method token is baked into the assembly. IronPython...
View ArticleVisualStudio as my IronPython editor
The following steps are what I did to get Visual Studio ready as my IronPython (and IronRuby) editor. Install the latest internal dogfood build of Visual Studio 2008. you may use Visual Studio 2005 or...
View ArticleIronPython: Accessing the .NET Field
The .NET libraries normally do not expose the public field, but we can still find its' presence for certain scenarios. IronPython treats the .NET fields like python attribute. For python attribute, the...
View ArticleILVisualizer VS2008 solution
I attached the ILVisualizer VS2008 solution in this post. There is no source code update; the only change is to upgrade the Microsoft.VisualStudio.DebuggerVisualizers.dll reference from version 8.0.0.0...
View Article