The property method has three additional characteristics compared to the conventional method:
- They always start with
get_ or set_ , while a regular CAN method can start with these prefixes. - The MethodInfo.IsSpecialName property is
MethodInfo.IsSpecialName to true. - MethodInfo has a custom attribute
System.Runtime.CompilerServices.CompilerGeneratedAttribute .
You can check 1, combined with option 2 or 3. Since prefixes are standard, you should not worry about checking on it.
Another method is to list all the properties and map the methods, which will be much slower:
public bool IsGetter(MethodInfo method) { if (!method.IsSpecialName) return false;
Martin mulder
source share