Browse by Tags

Tagged Content List
  • Blog Post: SignatureResolver (unfinished)

    While writing the ILVisualizer for dynamic method late 2005, I'd like to show the local variable information as well; so I started working on the managed signature parser, at least to parse LocalVarSig (Ecma-335 23.2.6). It was 2+ years ago, and never got to a finished state. Now perhaps I will never...
  • Blog Post: Name 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 use Type.GetType("System.Double[*]") to get hold of such type easily. To get an instance of such...
  • Blog Post: Late-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 ( Array.SetValue / Array.GetValue ). They are convenient to use. Let me start with some code to create an one-dimensional integer...
  • Blog Post: Take 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 opinion ). Recently along with the ILReader update, I made a few changes on the visualizer: Add support...
  • Blog Post: System.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 users can focus on their domain-specific logic by simply inheriting from it and overriding...
  • Blog Post: 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 two fields (F1, F2) in one type, I think the compiler is free to emit F1 before F2, or...
  • Blog Post: My Attribute Disappears

    The GetCustomAttributes scenario ( ICustomAttributeProvider.GetCustomAttributes or Attribute.GetCustomAttributes , referred to as GetCA in this post) involves 3 pieces: a custom attribute type an entity which is decorated with the custom attribute a code snippet calling GetCA on the...
  • Blog Post: Type.FullName returns null when ...

    Type.FullName returns null when the type is not generic type definition but contains generic paramters. The rational behind this design is to ensure Type.FullName (if not null) can uniquely identify a type in an assembly; or given the string returned by Type.FullName, Type.GetType (string...
  • Blog Post: Use IronPython to Experiment .NET Libraries

    When working on .NET projects, we often need to find the right API or the proper parameters to pass in to a particular method. Usually we search MSDN or turn to other search engines to solve such issue. Some people, however, prefer first-hand experience over search; they perfer experimenting or playing...
  • Blog Post: 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...
  • Blog Post: Read IL from MethodBody

    Reflection in .NET 2.0 ships with a new class MethodBody, which "provides access to information about the local variables and exception-handling clauses in a method body, and to the Microsoft intermediate language (MSIL) that makes up the method body". (Thanks to Glenn, who wrote this in the...
  • Blog Post: Nested Types in Generic Classes

    In C#, nested types can be defined in generic classes just like they would be in non-generic classes. For example: class G <T> { public class NestedC { } public enum NestedEnum { A, B } } Inside the nested type NestedC, we can still use type parameter T, which was "declared...
  • Blog Post: No LocalVariableInfo.Name?

    This was one ladybug in MSDN product feedback center. First of all, thanks to those who filed bugs or suggestions through it, which really help improve our product quality. No Name property in the LocalVariableInfo class is "by design" (possibly forever). Inside a .Net assembly, there...
  • Blog Post: Get Names and Values of Enum Members

    Yes, reflection can get this done. Assume we have an Enum type - Colors, the following code will print the name and value for each member of it. foreach ( FieldInfo fi in typeof ( Colors ).GetFields( BindingFlags .Public | BindingFlags .Static)) { Console .WriteLine(fi.Name); Console...
  • Blog Post: Reflection and Nullable<T>

    You might have already read this : VS2005 made the last-minute DCR related to boxed Nullable<T>. Runtime now treats Nullable<T> differently from other generic value types when boxing: Int32 ? x = null ; object y = x; // y is simply null, not a truly boxed "nullable<int>...
  • Blog Post: Type.GetType(string typeName) returns null !?

    Type.GetType gives us the ability to get type back from a string. We pass a well-written type name string to it, and expect it return that type. Sometimes, to your surprise, it returns null. For example, Type.GetType("System.Data.SqlClient.SqlException"). If the assembly name is specified in the typeName...
Page 1 of 1 (16 items)