public static TypeReference TryGetSpecificBaseType(this TypeReference specificTypeRef)
        {
            var typeDef = specificTypeRef.Resolve();

            if (typeDef.BaseType == null ||
                typeDef.BaseType.FullName == "System.Object")
            {
                return(null);
            }

            var specificBaseTypeRef = typeDef.BaseType;

            if (specificBaseTypeRef.ContainsGenericParameter)
            {
                var genericArgMap = new Dictionary <string, TypeReference>();

                foreach (var ancestor in specificTypeRef.AllNestParentsAndSelf())
                {
                    var specificTypeRefGenericInstance = ancestor as GenericInstanceType;

                    if (specificTypeRefGenericInstance != null)
                    {
                        for (int i = 0; i < typeDef.GenericParameters.Count; i++)
                        {
                            genericArgMap[typeDef.GenericParameters[i].Name] = specificTypeRefGenericInstance.GenericArguments[i];
                        }
                    }
                }

                specificBaseTypeRef = FillInGenericParameters(specificBaseTypeRef, genericArgMap);
            }

            return(specificBaseTypeRef);
        }