Skip to content

Commit

Permalink
Fix api surface generator to support overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Feb 16, 2024
1 parent bb29fd0 commit f939dcb
Showing 1 changed file with 39 additions and 25 deletions.
64 changes: 39 additions & 25 deletions ValveKeyValue/ValveKeyValue.Test/ApiSurfaceTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,41 +142,55 @@ static bool IsHidingMember(MethodInfo method)
return false;
}

var baseMethod = baseType.GetMethod(method.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (baseMethod == null)
{
return false;
}
var baseMethods = baseType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

if (baseMethod.DeclaringType == method.DeclaringType)
foreach (var baseMethod in baseMethods)
{
return false;
}
if (baseMethod.Name != method.Name)
{
continue;
}

var methodDefinition = method.GetBaseDefinition();
var baseMethodDefinition = baseMethod.GetBaseDefinition();
if (baseMethod.DeclaringType == method.DeclaringType)
{
continue;
}

if (methodDefinition.DeclaringType == baseMethodDefinition.DeclaringType)
{
return false;
}
var methodDefinition = method.GetBaseDefinition();
var baseMethodDefinition = baseMethod.GetBaseDefinition();

var methodParameters = method.GetParameters();
var baseMethodParameters = baseMethod.GetParameters();
if (methodParameters.Length != baseMethodParameters.Length)
{
return false;
}
if (methodDefinition.DeclaringType == baseMethodDefinition.DeclaringType)
{
continue;
}

for (int i = 0; i < methodParameters.Length; i++)
{
if (methodParameters[i].ParameterType != baseMethodParameters[i].ParameterType)
var methodParameters = method.GetParameters();
var baseMethodParameters = baseMethod.GetParameters();
if (methodParameters.Length != baseMethodParameters.Length)
{
return false;
continue;
}

var hasMatchingParameters = true;

for (int i = 0; i < methodParameters.Length; i++)
{
if (methodParameters[i].ParameterType != baseMethodParameters[i].ParameterType)
{
hasMatchingParameters = false;
break;
}
}

if (!hasMatchingParameters)
{
continue;
}

return true;
}

return true;
return false;
}

static string GetTypeAsString(Type type)
Expand Down

0 comments on commit f939dcb

Please sign in to comment.