I was thinking you might want to check the interfaces the type of the property implements. (Removed redundant interfaces, as IList inherits ICollection and ICollection inherits IEnumerable.)
static void DoSomething<T>()
{
List<Type> collections = new List<Type>() { typeof(IEnumerable<>), typeof(IEnumerable) };
foreach (PropertyInfo propertyInfo in typeof(T).GetProperties())
{
if (propertyInfo.PropertyType != typeof(string) && propertyInfo.PropertyType.GetInterfaces().Any(i => collections.Any(c => i == c)))
{
continue;
}
Console.WriteLine(propertyInfo.Name);
}
}
I added code to not reject string, as it implements IEnumerable, as well, and I figured you might want to keep those around.
In light of the redundancy of the prior list of collection interfaces, it may be simpler just to write the code like this
static void DoSomething<T>()
{
foreach (PropertyInfo propertyInfo in typeof(T).GetProperties())
{
if (propertyInfo.PropertyType != typeof(string)
&& propertyInfo.PropertyType.GetInterface(typeof(IEnumerable).Name) != null
&& propertyInfo.PropertyType.GetInterface(typeof(IEnumerable<>).Name) != null)
{
continue;
}
Console.WriteLine(propertyInfo.Name);
}
}