Skip to content

Commit

Permalink
Fixed polymorphic matching when a multi parameter Action delegate is …
Browse files Browse the repository at this point in the history
…matched
  • Loading branch information
almostchristian committed Nov 14, 2022
1 parent f32f2f8 commit 68daf4e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ private static List<MethodInfo> FindConfigurationExtensionMethods(
var genericArgs = configType.GetGenericArguments();
candidateMethods.AddRange(scannedTypes
.SelectMany(t => candidateNames != null ? candidateNames.SelectMany(n => t.GetDeclaredMethods(n)) : t.DeclaredMethods)
.Where(m => m.GetParameters().Select(p => p.ParameterType).Take(genericArgs.Length).SequenceEqual(genericArgs)));
.Where(m => m.GetParameters().Select(p => p.ParameterType).Take(genericArgs.Length).Zip(genericArgs, (a, b) => (a, b)).All(values => values.a.IsAssignableFrom(values.b))));
}

if (typeArgs == null || typeArgs.Length == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>1.10.0</Version>
<Version>1.10.1</Version>
<FileVersion>$(Version).$([System.DateTime]::Now.ToString(yy))$([System.DateTime]::Now.DayOfYear.ToString(000))</FileVersion>
<PackageVersion>$(Version)</PackageVersion>
<InformationalVersion>$(FileVersion)-$(GIT_VERSION)</InformationalVersion>
Expand Down
14 changes: 7 additions & 7 deletions tests/TestDummies/DummyServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public static IServiceCollection MultiParameterDelegate2(this IServiceCollection
return services;
}

public static IServiceCollection MultiParameterDelegate3(this IServiceCollection services, Action<ComplexObject, IChildValue, DbConnection> configurator)
public static IServiceCollection MultiParameterDelegate3(this IServiceCollection services, Action<ComplexObject, ComplexObject.ChildValue, DbConnection> configurator)
{
var complexObj = new ComplexObject { Value = new ComplexObject.ChildValue() };
var dbConn = new DbConnection();
Expand All @@ -347,7 +347,7 @@ public static IServiceCollection MultiParameterDelegate3(this IServiceCollection
return services;
}

public static IServiceCollection MultiParameterDelegate4(this IServiceCollection services, Action<ComplexObject, IChildValue, DbConnection, IComplexObject> configurator)
public static IServiceCollection MultiParameterDelegate4(this IServiceCollection services, Action<ComplexObject, ComplexObject.ChildValue, DbConnection, IComplexObject> configurator)
{
var complexObj = new ComplexObject { Value = new ComplexObject.ChildValue() };
var dbConn = new DbConnection();
Expand All @@ -367,7 +367,7 @@ public static IServiceCollection MultiParameterDelegate5(this IServiceCollection
return services;
}

public static IServiceCollection MultiParameterDelegate6(this IServiceCollection services, Action<ComplexObject, IChildValue, DbConnection, IComplexObject, IComplexObject, IComplexObject> configurator)
public static IServiceCollection MultiParameterDelegate6(this IServiceCollection services, Action<ComplexObject, ComplexObject.ChildValue, DbConnection, IComplexObject, IComplexObject, IComplexObject> configurator)
{
var complexObj = new ComplexObject { Value = new ComplexObject.ChildValue() };
var dbConn = new DbConnection();
Expand All @@ -387,7 +387,7 @@ public static IServiceCollection MultiParameterDelegate7(this IServiceCollection
return services;
}

public static IServiceCollection MultiParameterDelegate8(this IServiceCollection services, Action<ComplexObject, IChildValue, DbConnection, IComplexObject, IComplexObject, IComplexObject, IComplexObject, IComplexObject> configurator)
public static IServiceCollection MultiParameterDelegate8(this IServiceCollection services, Action<ComplexObject, ComplexObject.ChildValue, DbConnection, ComplexObject, ComplexObject, ComplexObject, ComplexObject, ComplexObject> configurator)
{
var complexObj = new ComplexObject { Value = new ComplexObject.ChildValue() };
var dbConn = new DbConnection();
Expand All @@ -414,7 +414,7 @@ public static void MultiConfigure(ComplexObject Obj, DbConnection Conn, string v
Conn.ConnectionString += value;
}

public static void MultiConfigure(ComplexObject Obj, IChildValue Child, DbConnection Conn, string value)
public static void MultiConfigure(ComplexObject Obj, ComplexObject.ChildValue Child, DbConnection Conn, string value)
{
Obj.Name += value;
Conn.ConnectionString += value;
Expand All @@ -432,7 +432,7 @@ public static void MultiConfigure(ComplexObject Obj, IChildValue Child, DbConnec
Conn.ConnectionString += value;
}

public static void MultiConfigure(ComplexObject Obj, IChildValue Child, DbConnection Conn, IComplexObject Obj1, IComplexObject Obj2, IComplexObject Obj3, string value)
public static void MultiConfigure(ComplexObject Obj, ComplexObject.ChildValue Child, DbConnection Conn, IComplexObject Obj1, IComplexObject Obj2, IComplexObject Obj3, string value)
{
Obj.Name += value;
Conn.ConnectionString += value;
Expand All @@ -444,7 +444,7 @@ public static void MultiConfigure(ComplexObject Obj, IChildValue Child, DbConnec
Conn.ConnectionString += value;
}

public static void MultiConfigure(ComplexObject Obj, IChildValue Child, DbConnection Conn, IComplexObject Obj1, IComplexObject Obj2, IComplexObject Obj3, IComplexObject Obj4, IComplexObject Obj5, string value)
public static void MultiConfigure(ComplexObject Obj, IChildValue Child, DbConnection Conn, ComplexObject Obj1, ComplexObject Obj2, ComplexObject Obj3, ComplexObject Obj4, ComplexObject Obj5, string value)
{
Obj.Name += value;
Conn.ConnectionString += value;
Expand Down

0 comments on commit 68daf4e

Please sign in to comment.