private static bool IsAnonymousType(Type type) {
return Attribute.IsDefined(type, typeof(CompilerGeneratedAttribute), false)
&& type.IsGenericType && type.Name.Contains("AnonymousType")
&& (type.Attributes & TypeAttributes.NotPublic) == TypeAttributes.NotPublic;
}