Skip to content

Instantly share code, notes, and snippets.

@EdVinyard
EdVinyard / IsOverride.cs
Created May 13, 2013 20:56
test if a method is an override; i.e., it overrides the implementation of the same method in a base class
using System.Reflection;
using NUnit.Framework;
public static class MethodInfoExtensions
{
public static bool IsOverride(this MethodInfo m)
{
return m.GetBaseDefinition().DeclaringType != m.DeclaringType;
}
}
@EdVinyard
EdVinyard / IsOverrideTests.cs
Created May 13, 2013 20:26
Attempt to validate behavior of IsOverridden implementation suggested by http://stackoverflow.com/a/10020948/150
using System.Reflection;
using NUnit.Framework;
public class IsOverrideTests
{
abstract class Base
{
public virtual void Overridden() { }
public virtual void Inherited() { }
}