public static IMemberDefinition ResolveDefinitionInRole(this IMemberDefinition member, TypeReference role)
 {
     var finder = new MemberFinder(role);
       string aliasing;
       if (member.IsAliasing(out aliasing)) {
     return finder.FindMatchFor(member, aliasing);
       }
       else {
     return finder.FindMatchFor(member);
       }
 }
 private MethodReference ResolveNewMethodReference(MethodReference oldMethod)
 {
     var finder = new MemberFinder(_type);
       var newMethod = (MethodDefinition)finder.FindMatchFor(
     new MemberResolver(oldMethod.DeclaringType).ResolveMethodDefinition(
       oldMethod.Resolve(),
       NameProvider.GetVirtualBaseMethodName(oldMethod.DeclaringType.Name, oldMethod.Name),
       oldMethod.Resolve().Attributes));
       if (newMethod == null) throw new InvalidOperationException();
       return newMethod;
 }
        private void ImplementBaseMethod(RoleCompositionMember typeMember, IEnumerable<RoleCompositionMember> overrides)
        {
            Tracer.TraceVerbose("Implement base method: {0}", typeMember.Definition);

              string baseMethodName = NameProvider.GetOriginalBaseMethodName(typeMember.Definition.Name);
              ClassMember baseMember = null;
              var currentType = TargetType.BaseType;
              do {
            var finder = new MemberFinder(currentType.Resolve());
            var foundBase = finder.FindMatchFor(typeMember.Definition, baseMethodName);
            if (foundBase != null) {
              baseMember = new ClassMember(currentType, foundBase, isInherited: true);
              break;
            }
            currentType = currentType.Resolve().BaseType;
              } while (currentType != null);
              if (baseMember == null) throw new InvalidOperationException();

              // TODO: refactor with AdjustSupercedingMember!
              var method = (MethodDefinition)typeMember.Definition;
              var targetMethod = new MemberResolver(baseMember.Class, Module).ResolveMethodDefinition(method, method.Name, MethodAttributes.Private | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.HideBySig);
              CreateCodeToCallBaseClassMethod(targetMethod, baseMember);
              TargetType.Methods.Add(targetMethod);
              AddOverrides(targetMethod, overrides);
        }