Resolved MethodDefinition for System.Collections.Generic.List.Add has IsVirtual = true #149
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm trying to figure out why this would be the case. System.Collections.Generic.List.Add is very definitely not virtual, here's the source from mono's corlib implementation:
However, Cecil says that it is virtual when I resolve a MethodReference and get a MethodDefinition for the method. The MethodDefinition is definitely coming from mscorlib and it points to the expected method.
Is this an expected behavior? The only explanation I can think of is that Add silently becomes virtual because it is being used to implement an 'Add' method on some particular interface, but that seems counterintuitive and I've never seen it specified as 'correct' behavior.
Yeah it's expected :)
The method implicitly implements ICollection`1.Add and needs a slot in the vtable to be called if called through the interface.
Thanks, that makes more sense. I should have checked the IL.