private static bool IsCompilerGenerated(Type type) { return type.GetCustomAttributes(inherit: true) .OfType<CompilerGeneratedAttribute>() .Any(); } }