I have a class with a single method that uses a \"yield\" return statement. A nested type is automatically created. Using reflection with binding flags set to BindingF
BindingF
You can test if the type has the [CompilerGenerated] attribute:
[CompilerGenerated]
if (type.GetCustomAttribute(typeof(CompilerGeneratedAttribute), true) != null) { ... }
Alternatively, you can check if the name contains characters that wouldn't be valid in user code.