public static ITypeSignature GetDeclaringType(this ITypeSignature typeSig) { typeSig = typeSig.GetLastElementType(); if (typeSig.ElementCode == TypeElementCode.GenericType) { typeSig = typeSig.DeclaringType; } if (typeSig.ElementCode == TypeElementCode.DeclaringType) { return(typeSig); } return(null); }