This answer really helped me! Here is the code I need to add in order to check the Type for CompilerGeneratedAttribute , as Valentin Kuzub said:
using System.Runtime.CompilerServices; //... bool IsCompilerGenerated(Type t) { var attr = Attribute.GetCustomAttribute(t, typeof(CompilerGeneratedAttribute)); return attr != null; }
source share