using System.Collections.Generic;
public static void Main()
List<Type> types = new List<Type>{typeof(A), typeof(B), typeof(C), typeof(ANotState), typeof(BNotState)};
var assemblies = new Dictionary<Assembly, Mono.Cecil.AssemblyDefinition>();
Func<System.Type, Mono.Cecil.TypeDefinition> getTypeDef = (t) =>
Mono.Cecil.AssemblyDefinition ad;
if (!assemblies.TryGetValue(t.Assembly, out ad))
var path = new Uri(t.Assembly.CodeBase).LocalPath;
ad = Mono.Cecil.AssemblyDefinition.ReadAssembly(path);
assemblies[t.Assembly] = ad;
return ad.MainModule.GetType(t.FullName);
var isStateTypeDef = getTypeDef(typeof(isState));
for (int i = types.Count - 1; i >= 0; i--)
var typeInfo = type.GetTypeInfo();
if (!typeInfo.ImplementedInterfaces.Contains(typeof(isState)))
Console.WriteLine("TypeInfo excluded " + type.Name);
if (!type.GetInterfaces().Contains(typeof(isState)))
Console.WriteLine("Type.GetInterfaces excluded " + type.Name);
var typeDef = getTypeDef(type);
if (!typeDef.Interfaces.Where((x) => x.InterfaceType == isStateTypeDef).Any())
Console.WriteLine("Cecil excluded:" + type.Name);
public interface isState{}
public abstract class B : A, isState
public abstract class C : B, isState
public class ANotState : C
public class BNotState : ANotState