public static bool IsAnonymousType(Type type)
{
if (type == null)
throw new ArgumentNullException("type");
return (type.IsClass
&& type.IsSealed
&& type.BaseType == typeof(object)
&& type.Name.StartsWith("<>", StringComparison.Ordinal)
&& type.IsDefined(typeof(CompilerGeneratedAttribute), true));
}
}