Hey Jason,

On 11/5/08, JasonBock <[EMAIL PROTECTED]> wrote:
>  Let's say I have a TypeDefinition for a class called SubClass.
>  SubClass descends from BaseClass. BaseClass has a number of public
>  properties on it. SubClass doesn't have any. The Properties collection
>  for SubClass contains no values - i.e. its Count is zero. This was
>  unexpected - I thought Cecil would "flatten" things out and give me
>  those properties from BaseClass.
>
>  Is there a way to get all of the properties for a TypeDefinition, base
>  class(es) included (i.e. all the way up to the root)? I looked at
>  DeclaringType but that gives me a TypeReference which doesn't have
>  Properties on it.

The issue here is that Cecil's type system is quite different from the
System.Reflection one. Because in System.Reflection all referenced
assemblies have to be loaded, there's no distinction between a
reference and a definition.

Cecil does this distinction. So it could be that the .BaseType of a
TypeDefinition is a TypeReference, which of course, doesn't have any
information but its name and scope.

What we do usually is use something to Resolve a TypeReference into a
TypeDefinition, to better analyze it.

Such a resolver will make it into the next version of Cecil, but for
the time being, people are usually using the one I wrote for the
linker, which is available here:

http://anonsvn.mono-project.com/viewvc/trunk/mcs/tools/linker/Mono.Linker/AssemblyResolver.cs?revision=HEAD&content-type=text%2Fplain

So by walking down the inheritance chain, and resolving the
references, you'll be able to collect all inherited properties.

-- 
Jb Evain  <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to