GetProperty reflection results in "Ambiguous match found" on new property
See the question and my original answer on StackOverflowFWIW, this is the code I use:
public static PropertyInfo GetUnambiguousProperty(object component, string name, BindingFlags flags = BindingFlags.Public | BindingFlags.Instance) => GetUnambiguousProperty(component?.GetType(), name, flags);
public static PropertyInfo GetUnambiguousProperty(Type type, string name, BindingFlags flags = BindingFlags.Public | BindingFlags.Instance)
{
if (type == null)
throw new ArgumentNullException(nameof(type));
if (name == null)
throw new ArgumentNullException(nameof(name));
return type.GetProperties(flags).Where(p => p.Name == name).FirstOrDefault();
}