in sdk/Sdk/FunctionMetadataGenerator.cs [663:703]
private static string? ResolveIEnumerableOfTType(TypeReference type, Dictionary<string, string> foundMapping)
{
// Base case:
// We are at IEnumerable<T> and want to return the most recent resolution of T
// (Most recent is relative to IEnumerable<T>)
if (string.Equals(type.FullName, Constants.IEnumerableOfT, StringComparison.Ordinal))
{
if (foundMapping.TryGetValue(Constants.GenericIEnumerableArgumentName, out string typeName))
{
return typeName;
}
return null;
}
TypeDefinition definition = type.Resolve();
if (definition.HasGenericParameters && type is GenericInstanceType genericType)
{
for (int i = 0; i < genericType.GenericArguments.Count(); i++)
{
string name = genericType.GenericArguments.ElementAt(i).FullName;
string resolvedName = definition.GenericParameters.ElementAt(i).FullName;
if (foundMapping.TryGetValue(name, out string firstType))
{
foundMapping.Remove(name);
foundMapping.Add(resolvedName, firstType);
}
else
{
foundMapping.Add(resolvedName, name);
}
}
}
return definition.Interfaces
.Select(i => ResolveIEnumerableOfTType(i.InterfaceType, foundMapping))
.FirstOrDefault(name => name is not null)
?? ResolveIEnumerableOfTType(definition.BaseType, foundMapping);
}