ConstructorInfo DetermineConstructor(MarkupExtensionParts parameter, IEvaluation[] candidates, TypeInfo type) { var specification = new ValidMarkupExtensionConstructor(candidates.ToImmutableArray()); var constructors = new QueriedConstructors(specification, _constructors); var constructor = constructors.Get(type); if (constructor == null) { var values = parameter.Arguments.Select(x => x.ToString()) .ToArray(); var primary = new InvalidOperationException( $"An attempt was made to activate a markup extension of type '{type}' and the constructor parameters values '{string.Join(", ", values)}', but a constructor could not be located that would accept these values. Please see any associated exceptions for any errors encountered while evaluating these parameter values."); var exceptions = primary.Yield() .Concat(candidates.Select(x => x.Get()) .Where(x => x != null)); throw new AggregateException(exceptions); } return(constructor); }