private static MethodDefinition GetSmallestConstructorFrom (TypeReference type) { IList<MethodDefinition> ctors = type.GetConstructors ().ToList (); if (ctors.Count == 1) return ctors [0]; MethodDefinition smallest = null; int scount = 0; foreach (MethodDefinition constructor in ctors) { // skip the static ctor since it will always be the smallest one if (constructor.IsStatic) continue; if (smallest == null) { smallest = constructor; scount = smallest.HasParameters ? smallest.Parameters.Count : 0; } else { int ccount = constructor.HasParameters ? constructor.Parameters.Count : 0; if (scount > ccount) { smallest = constructor; scount = ccount; } } } return smallest; }