|
|
|
@ -39,6 +39,46 @@ namespace ICSharpCode.NRefactory.TypeSystem
@@ -39,6 +39,46 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|
|
|
|
{ |
|
|
|
|
return GetBaseMembers(member, false).FirstOrDefault(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static IEnumerable<IMember> GetBaseAccessors(IMethod accessor, bool includeImplementedInterfaces) { |
|
|
|
|
IMember accessorOwner = accessor.AccessorOwner; |
|
|
|
|
SpecializedMember specializedMember = accessor as SpecializedMember; |
|
|
|
|
|
|
|
|
|
foreach (IMember baseOwner in GetBaseMembers(accessorOwner, includeImplementedInterfaces)) { |
|
|
|
|
if (accessorOwner is IProperty && baseOwner is IProperty) { |
|
|
|
|
var accessorProperty = (IProperty)accessorOwner; |
|
|
|
|
var baseProperty = (IProperty)baseOwner; |
|
|
|
|
if (accessor == accessorProperty.Getter && baseProperty.CanGet) { |
|
|
|
|
if (specializedMember != null) |
|
|
|
|
yield return SpecializedMember.Create(baseProperty.Getter, specializedMember.Substitution); |
|
|
|
|
else |
|
|
|
|
yield return baseProperty.Getter; |
|
|
|
|
} |
|
|
|
|
if (accessor == accessorProperty.Setter && baseProperty.CanSet) { |
|
|
|
|
if (specializedMember != null) |
|
|
|
|
yield return SpecializedMember.Create(baseProperty.Setter, specializedMember.Substitution); |
|
|
|
|
else |
|
|
|
|
yield return baseProperty.Setter; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (accessorOwner is IEvent && baseOwner is IEvent) { |
|
|
|
|
var accessorEvent = (IEvent)accessorOwner; |
|
|
|
|
var baseEvent = (IEvent)baseOwner; |
|
|
|
|
if (accessor == accessorEvent.AddAccessor && baseEvent.CanAdd) { |
|
|
|
|
if (specializedMember != null) |
|
|
|
|
yield return SpecializedMember.Create(baseEvent.AddAccessor, specializedMember.Substitution); |
|
|
|
|
else |
|
|
|
|
yield return baseEvent.AddAccessor; |
|
|
|
|
} |
|
|
|
|
if (accessor == accessorEvent.RemoveAccessor && baseEvent.CanRemove) { |
|
|
|
|
if (specializedMember != null) |
|
|
|
|
yield return SpecializedMember.Create(baseEvent.RemoveAccessor, specializedMember.Substitution); |
|
|
|
|
else |
|
|
|
|
yield return baseEvent.RemoveAccessor; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets all base members that have the same signature.
|
|
|
|
@ -50,7 +90,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
@@ -50,7 +90,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|
|
|
|
{ |
|
|
|
|
if (member == null) |
|
|
|
|
throw new ArgumentNullException("member"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (member.IsExplicitInterfaceImplementation && member.ImplementedInterfaceMembers.Count == 1) { |
|
|
|
|
// C#-style explicit interface implementation
|
|
|
|
|
member = member.ImplementedInterfaceMembers[0]; |
|
|
|
@ -59,6 +99,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
@@ -59,6 +99,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|
|
|
|
|
|
|
|
|
SpecializedMember specializedMember = member as SpecializedMember; |
|
|
|
|
member = member.MemberDefinition; |
|
|
|
|
|
|
|
|
|
if (member is IMethod && ((IMethod)member).IsAccessor) { |
|
|
|
|
foreach (IMember m in GetBaseAccessors((IMethod)member, includeImplementedInterfaces)) |
|
|
|
|
yield return m; |
|
|
|
|
yield break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IEnumerable<IType> allBaseTypes; |
|
|
|
|
if (includeImplementedInterfaces) { |
|
|
|
@ -70,53 +116,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
@@ -70,53 +116,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
|
|
|
|
|
if (baseType == member.DeclaringTypeDefinition) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
if (member is IMethod && ((IMethod)member).IsAccessor) { |
|
|
|
|
var accessorOwner = ((IMethod)member).AccessorOwner; |
|
|
|
|
foreach (IMember baseOwner in baseType.GetMembers(m => m.Name == accessorOwner.Name, GetMemberOptions.IgnoreInheritedMembers)) { |
|
|
|
|
if (SignatureComparer.Ordinal.Equals(accessorOwner, baseOwner)) { |
|
|
|
|
if (accessorOwner is IProperty && baseOwner is IProperty) { |
|
|
|
|
var accessorProperty = (IProperty)accessorOwner; |
|
|
|
|
var baseProperty = (IProperty)baseOwner; |
|
|
|
|
if (member == accessorProperty.Getter && baseProperty.CanGet) { |
|
|
|
|
if (specializedMember != null) |
|
|
|
|
yield return SpecializedMember.Create(baseProperty.Getter, specializedMember.Substitution); |
|
|
|
|
else |
|
|
|
|
yield return baseProperty.Getter; |
|
|
|
|
} |
|
|
|
|
if (member == accessorProperty.Setter && baseProperty.CanSet) { |
|
|
|
|
if (specializedMember != null) |
|
|
|
|
yield return SpecializedMember.Create(baseProperty.Setter, specializedMember.Substitution); |
|
|
|
|
else |
|
|
|
|
yield return baseProperty.Setter; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (accessorOwner is IEvent && baseOwner is IEvent) { |
|
|
|
|
var accessorEvent = (IEvent)accessorOwner; |
|
|
|
|
var baseEvent = (IEvent)baseOwner; |
|
|
|
|
if (member == accessorEvent.AddAccessor && baseEvent.CanAdd) { |
|
|
|
|
if (specializedMember != null) |
|
|
|
|
yield return SpecializedMember.Create(baseEvent.AddAccessor, specializedMember.Substitution); |
|
|
|
|
else |
|
|
|
|
yield return baseEvent.AddAccessor; |
|
|
|
|
} |
|
|
|
|
if (member == accessorEvent.RemoveAccessor && baseEvent.CanRemove) { |
|
|
|
|
if (specializedMember != null) |
|
|
|
|
yield return SpecializedMember.Create(baseEvent.RemoveAccessor, specializedMember.Substitution); |
|
|
|
|
else |
|
|
|
|
yield return baseEvent.RemoveAccessor; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
foreach (IMember baseMember in baseType.GetMembers(m => m.Name == member.Name, GetMemberOptions.IgnoreInheritedMembers)) { |
|
|
|
|
if (SignatureComparer.Ordinal.Equals(member, baseMember)) { |
|
|
|
|
if (specializedMember != null) |
|
|
|
|
yield return SpecializedMember.Create(baseMember, specializedMember.Substitution); |
|
|
|
|
else |
|
|
|
|
yield return baseMember; |
|
|
|
|
} |
|
|
|
|
foreach (IMember baseMember in baseType.GetMembers(m => m.Name == member.Name, GetMemberOptions.IgnoreInheritedMembers)) { |
|
|
|
|
if (SignatureComparer.Ordinal.Equals(member, baseMember)) { |
|
|
|
|
if (specializedMember != null) |
|
|
|
|
yield return SpecializedMember.Create(baseMember, specializedMember.Substitution); |
|
|
|
|
else |
|
|
|
|
yield return baseMember; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|