/// <inheritdoc /> public MutableMethodInfo GetOverride(MethodInfo baseDefinition, IEnumerable <MutableMethodInfo> overrideCandidates) { ArgumentUtility.CheckNotNull("baseDefinition", baseDefinition); ArgumentUtility.CheckNotNull("overrideCandidates", overrideCandidates); Assertion.DebugAssert(s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(baseDefinition))); return(overrideCandidates.SingleOrDefault( m => s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(m)) || m.AddedExplicitBaseDefinitions.Contains(baseDefinition, s_memberInfoEqualityComparer))); }
/// <inheritdoc /> public bool IsShadowed(MethodInfo baseDefinition, IEnumerable <MethodInfo> shadowingCandidates) { ArgumentUtility.CheckNotNull("baseDefinition", baseDefinition); ArgumentUtility.CheckNotNull("shadowingCandidates", shadowingCandidates); Assertion.DebugAssert(s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(baseDefinition))); return(shadowingCandidates.Any( m => m.Name == baseDefinition.Name && MethodSignature.AreEqual(m, baseDefinition) && baseDefinition.DeclaringType.IsTypePipeAssignableFrom(m.DeclaringType.BaseType) && !s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(m)))); }
/// <inheritdoc /> public MethodInfo GetBaseMethod(MethodInfo method) { ArgumentUtility.CheckNotNull("method", method); Assertion.IsNotNull(method.DeclaringType); var baseDefinition = MethodBaseDefinitionCache.GetBaseDefinition(method); if (baseDefinition.DeclaringType.BaseType == null) { return(null); } return(GetMostDerivedOverride(baseDefinition, method.DeclaringType.BaseType)); }
private bool HasSameBaseDefinition(MethodInfo a, MethodInfo b) { return(MethodBaseDefinitionCache.GetBaseDefinition(a) == MethodBaseDefinitionCache.GetBaseDefinition(b)); }
/// <inheritdoc /> public MethodInfo GetMostDerivedOverride(MethodInfo baseDefinition, Type typeToStartSearch) { ArgumentUtility.CheckNotNull("baseDefinition", baseDefinition); ArgumentUtility.CheckNotNull("typeToStartSearch", typeToStartSearch); Assertion.DebugAssert(s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(baseDefinition))); Func <MethodInfo, bool> predicate = m => s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(m)); return(FirstOrDefaultFromOrderedBaseMethods(typeToStartSearch, predicate)); }
private bool SafeHasSameBaseDefinition(MethodInfo a, MethodInfo b) { return(a != null && b != null && MethodBaseDefinitionCache.GetBaseDefinition(a) == MethodBaseDefinitionCache.GetBaseDefinition(b)); }