On Mon, 2009-08-17 at 11:33 -0700, Joe White wrote:
> But I don't know how to walk a TypeDefinition's ancestry. I found
> TypeDefinition.BaseType, which looks like it should get me from a
> TypeDefinition to its base class. However, BaseType is of type
> TypeReference, not TypeDefinition. TypeReference doesn't have a
> BaseType, so I can't keep walking up the inheritance tree.
The base type may belong to a different assembly, which is why it's a
TypeReference. To obtain a TypeDefinition (to continue walking the
inheritance chain), you need to call TypeReference.Resolve():
TypeDefinition type = ...;
while (type != null) {
// ...
type = type.BaseType != null
? type.Base.Resolve ()
: null;
}
- Jon
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---