private IMethodDefinition FindBestMatch(IMethodDefinition matchMethod, TypeMapping mapping, int typeIndex, int memberIndex)
        {
            // No matches if we don't have a matching type.
            if (mapping[typeIndex] == null)
                return null;

            foreach (IMethodDefinition method in mapping[typeIndex].Methods)
            {
                if (method.Name.Value != matchMethod.Name.Value) continue;

                if (method.ParameterCount != matchMethod.ParameterCount) continue;

                if (method.IsGeneric && matchMethod.IsGeneric &&
                    method.GenericParameterCount != matchMethod.GenericParameterCount)
                    continue;

                MemberMapping member = mapping.FindMember(method);

                // It is possible to find a match that was filtered at the mapping layer
                if (member == null) continue;

                // If the other member also doesn't have a match then this is our best match
                if (member[memberIndex] == null)
                    return method;
            }

            return null;
        }
        private IMethodDefinition FindBestMatch(IMethodDefinition matchMethod, TypeMapping mapping, int typeIndex, int memberIndex)
        {
            // No matches if we don't have a matching type.
            if (mapping[typeIndex] == null)
            {
                return(null);
            }

            foreach (IMethodDefinition method in mapping[typeIndex].Methods)
            {
                if (method.Name.Value != matchMethod.Name.Value)
                {
                    continue;
                }

                if (method.ParameterCount != matchMethod.ParameterCount)
                {
                    continue;
                }

                if (method.IsGeneric && matchMethod.IsGeneric &&
                    method.GenericParameterCount != matchMethod.GenericParameterCount)
                {
                    continue;
                }

                MemberMapping member = mapping.FindMember(method);

                // It is possible to find a match that was filtered at the mapping layer
                if (member == null)
                {
                    continue;
                }

                // If the other member also doesn't have a match then this is our best match
                if (member[memberIndex] == null)
                {
                    return(method);
                }
            }

            return(null);
        }