Overrides is used exclusively for cases where the base method can't be
implicitely discovered. (C#'s explicit interface implementation for
instance).
You can use the GetBaseMethod extension method to navigate implicitly
overriden methods.
--
--
mono-cecil
You indeed have to check whether they're virtual. You also have to
differentiate NewSlot/ReuseSlot methods for shadowing or overriding.
--
--
mono-cecil
class Base
{
public virtual void M() { }
}
class Derived
{
public new virtual void M() { }
}
In this case, Base.M() is virtual (and not final), but Derived.M() is
not an override. You can see this in the metadata because Derived.M()
has the NewSlot flag set. Methods with NewSlot are never implicit
overrides of base methods.
Cheers,
Fabian
> On Tue, Oct 26, 2010 at 3:58 PM, Greg Young <gregor...@gmail.com> wrote:
>>
>> Ah yes ... That should do it thanks JB.
>>
>> On Tue, Oct 26, 2010 at 3:46 PM, Jb Evain <jbe...@gmail.com> wrote:
>>>
>>> On Tue, Oct 26, 2010 at 9:42 PM, Greg Young <gregor...@gmail.com>
>>> wrote:
>>> > but I guess I could just look if A::Foo is virtual. Not sure if that is
>>> > good
>>> > enough, will have to check ECMA docs.
>>>
>>> You indeed have to check whether they're virtual. You also have to
>>> differentiate NewSlot/ReuseSlot methods for shadowing or overriding.
>>>
>>> --
>>> --
>>> mono-cecil
>>
>>
>> --
>> Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer de
>> votre attention
>
>
>
> --
> Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer de
> votre attention
>
> --
> --
> mono-cecil
using System;
class Foo {
public virtual void Do ()
{
Console.WriteLine ("Foo::Do");
}
}
class Bar : Foo {
public override void Do ()
{
Console.WriteLine ("Bar::Do");
}
}
class Baz : Bar {
public new virtual void Do ()
{
Console.WriteLine ("Baz::Do");
}
}
class Gazonk : Baz {
public override void Do ()
{
Console.WriteLine ("Gazonk::Do");
}
}
class Program {
static void Main ()
{
Foo f = new Gazonk ();
f.Do ();
Baz b = f as Baz;
b.Do ();
}
}
mcs, Mono's C# compiler? Please, it's basic C#, mcs deals with that
without any issue :)
In that case, Baz::Do is marked as NewSlot, as it should.
--
--
mono-cecil
The linker is a particular case. Removing virtual methods is not
trivial, so it takes the whole method chain, whether they have a
NewSlot or not.
.method public newslot virtual final instance void
Woo() cil managed
{
.override Base::Boo
.maxstack 1
//...
IL_000a: ret
}
--
--
mono-cecil
I'm not exactly sure what you want here. Please be more specific or
include a piece of code showing what you have and what you would like.
Check the Overrides collection, it should be in there, if I'm not mistaken.
And with that, this thread has gone to where it originally started :)
Fabian
> --
> --
> mono-cecil
--
--
mono-cecil