Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ private ServiceCallSite CreateConstructorCallSite(
}

parameterCallSites = CreateArgumentCallSites(
serviceType,
implementationType,
callSiteChain,
parameters,
Expand All @@ -304,7 +303,6 @@ private ServiceCallSite CreateConstructorCallSite(
ParameterInfo[] parameters = constructors[i].GetParameters();

ServiceCallSite[] currentParameterCallSites = CreateArgumentCallSites(
serviceType,
implementationType,
callSiteChain,
parameters,
Expand All @@ -324,19 +322,24 @@ private ServiceCallSite CreateConstructorCallSite(

if (bestConstructorParameterTypes == null)
{
bestConstructorParameterTypes = new HashSet<Type>(
bestConstructor.GetParameters().Select(p => p.ParameterType));
bestConstructorParameterTypes = new HashSet<Type>();
foreach (ParameterInfo p in bestConstructor.GetParameters())
{
bestConstructorParameterTypes.Add(p.ParameterType);
}
}

if (!bestConstructorParameterTypes.IsSupersetOf(parameters.Select(p => p.ParameterType)))
foreach (ParameterInfo p in parameters)
{
// Ambiguous match exception
string message = string.Join(
Environment.NewLine,
SR.Format(SR.AmbiguousConstructorException, implementationType),
bestConstructor,
constructors[i]);
throw new InvalidOperationException(message);
if (!bestConstructorParameterTypes.Contains(p.ParameterType))
{
// Ambiguous match exception
throw new InvalidOperationException(string.Join(
Environment.NewLine,
SR.Format(SR.AmbiguousConstructorException, implementationType),
bestConstructor,
constructors[i]));
}
}
}
}
Expand All @@ -360,7 +363,6 @@ private ServiceCallSite CreateConstructorCallSite(
}

private ServiceCallSite[] CreateArgumentCallSites(
Type serviceType,
Type implementationType,
CallSiteChain callSiteChain,
ParameterInfo[] parameters,
Expand Down