Alex Rivera | Logout

Mono.Cecil type.IsAssignableFrom(derivedType) equivalent

Asked 2011-04-15T10:22:38.817
11

I'm using Mono.Cecil to find types in Assembly that are derived from given on. Normaly it can be done with IsAssignableFrom() method, but I cannot fing it's equivalent in Cecil. Is there any such method or other way to check it? Thanks Mike

Edit
Report

1 Answer

1

One method to find derived types of type AType is to enumerate all types defined in the assembly and compare their BaseType property to the type AType. This method is used in ILSpy to show derived types of a selected type. Implementation is in FindDerivedTypes method (DerivedTypesTreeNode.cs). To find types derived indirectly you have to iterate over BaseType property (using Resolve()) until the AType is reached or BaseType is equal to null.

answered 2011-04-20T18:33:22.747

Your Answer