- ArrayList al = new ArrayList (ml.Count);
- for (int i = 0; i < ml.Count; i++) {
- MethodBase x = ml [i] as MethodBase;
- if (x != null && x.DeclaringType != type && x.IsVirtual && !TypeManager.IsOverride (x))
- continue;
+ if (ml == null)
+ return empty_member_infos;
+
+ return FilterOverridenMembersOut ((MemberInfo []) ml);
+ }
+
+ static bool IsOverride (PropertyInfo deriv_prop, PropertyInfo base_prop)
+ {
+ if (!MethodGroupExpr.IsAncestralType (base_prop.DeclaringType, deriv_prop.DeclaringType))
+ return false;
+
+ Type [] deriv_pd = TypeManager.GetParameterData (deriv_prop).Types;
+ Type [] base_pd = TypeManager.GetParameterData (base_prop).Types;
+
+ if (deriv_pd.Length != base_pd.Length)
+ return false;
+
+ for (int j = 0; j < deriv_pd.Length; ++j) {
+ if (deriv_pd [j] != base_pd [j])
+ return false;
+ Type ct = TypeManager.TypeToCoreType (deriv_pd [j]);
+ Type bt = TypeManager.TypeToCoreType (base_pd [j]);
+
+ if (ct != bt)
+ return false;
+ }
+
+ return true;
+ }
+
+ private static MemberInfo [] FilterOverridenMembersOut (
+ MemberInfo [] ml)
+ {
+ if (ml == null)
+ return empty_member_infos;
+
+ ArrayList al = new ArrayList (ml.Length);
+ for (int i = 0; i < ml.Length; i++) {
+ MethodBase mx = ml [i] as MethodBase;
+ PropertyInfo px = ml [i] as PropertyInfo;
+ if (mx != null || px != null) {
+ bool overriden = false;
+ for (int j = 0; j < ml.Length; j++) {
+ if (j == i)
+ continue;
+ MethodBase my = ml [j] as MethodBase;
+ if (mx != null && my != null &&
+ MethodGroupExpr.IsOverride (my, mx)) {
+ overriden = true;
+ break;
+ }
+ else if (mx != null)
+ continue;
+ PropertyInfo py = ml [j] as PropertyInfo;
+ if (px != null && py != null &&
+ IsOverride (py, px)) {
+ overriden = true;
+ break;
+ }
+ }
+ if (overriden)
+ continue;
+ }