Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #837 from jpbruyere/CodeTemplateFix
Browse files Browse the repository at this point in the history
[code] Fix Generic collection argument type return for code template
  • Loading branch information
slluis committed Jun 10, 2015
2 parents 18432cc + 5dd383d commit ca5f9c2
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,19 @@ public string GetLengthProperty (Func<string, string> callback, string varName)

IType GetElementType (IType result)
{
IType tmp = null;
foreach (var baseType in result.GetAllBaseTypes ()) {
var baseTypeDef = baseType.GetDefinition();
if (baseTypeDef != null && baseTypeDef.Name == "IEnumerable") {
if (baseTypeDef.Namespace == "System.Collections.Generic" && baseTypeDef.TypeParameterCount == 1) {
if (baseType.TypeArguments.Count > 0)
return baseType.TypeArguments[0];
} else if (baseTypeDef.Namespace == "System.Collections" && baseTypeDef.TypeParameterCount == 0) {
return CurrentContext.Compilation.FindType (KnownTypeCode.Object);
tmp = CurrentContext.Compilation.FindType (KnownTypeCode.Object);
}
}
}
return new UnknownType ("", "", 0);
return tmp == null ? new UnknownType ("", "", 0) : tmp;
}


Expand Down

0 comments on commit ca5f9c2

Please sign in to comment.