Thanks.
My test class looks the following:
public class Class1
{
private String test2 = "bla";
public void Test3()
{
Console.WriteLine(test2);
}
}
class Test : Class1
{
public void Test3()
{
}
}
So my code to check is:
foreach (MethodDefinition method in type.Methods)
{
if (method.IsVirtual && !method.IsNewSlot)
{
Console.WriteLine("Inherited");
}
if (method.IsPublic)
{
totalMethods++;
if (!method.IsSetter && !method.IsGetter)
{
nonAccessorMethods++;
}
}
}
However, Inherited is never printed on the console, and both classes have a
total amount of methods of 1
What I am doing wrong?
2010/11/25 Jb Evain <[email protected]>
> Hi,
>
> On Thu, Nov 25, 2010 at 12:32 AM, Sebastian Müller
> <[email protected]> wrote:
> > I parse trough the MethodDefinition s of a type. How can I detect if the
> > method is inherited from a base class?
>
> The .Methods on the type only contain the methods that are actually
> declared on the type. You can check its attributes to know if it's
> IsVirtual and !IsNewSlot, in which case it's an overriden method.
>
> Jb
>
> --
> --
> mono-cecil
--
--
mono-cecil