Skip to content

Commit

Permalink
fixes method selector
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo committed Jun 23, 2020
1 parent 0e8fa40 commit 93add75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/Wanhjor.ObjectInspector/DuckType.Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,21 @@ private static void CreateMethods(Type baseType, Type instanceType, FieldInfo in
return method;

allMethods ??= instanceType.GetMethods(duckAttr.Flags);
// Trying to select the ones with the same parameters count

// Trying to select the one with the same name
var remaining = allMethods.Where(m =>
{
if (m.Name == duckAttr.Name) return true;
return m.ToString() == duckAttr.Name;
}).ToList();

if (remaining.Count == 0)
continue;
if (remaining.Count == 1)
return remaining[0];

// Trying to select the ones with the same parameters count
remaining = remaining.Where(m =>
{
if (m.Name != duckAttr.Name) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Wanhjor.ObjectInspector/Wanhjor.ObjectInspector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Description>An efficient .NET object inspector/accesor to avoid reflection usage with duck typing support.</Description>
<LangVersion>8</LangVersion>
<Nullable>enable</Nullable>
<Version>0.4.0-beta.5</Version>
<Version>0.4.0-beta.6</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>ObjectInspector</Title>
<Authors>Daniel Redondo</Authors>
Expand Down

0 comments on commit 93add75

Please sign in to comment.