diff --git a/src/Xamarin.Android.Tools.ApiXmlAdjuster/JavaTypeName.cs b/src/Xamarin.Android.Tools.ApiXmlAdjuster/JavaTypeName.cs index 9902a95e7..4f7d1877e 100644 --- a/src/Xamarin.Android.Tools.ApiXmlAdjuster/JavaTypeName.cs +++ b/src/Xamarin.Android.Tools.ApiXmlAdjuster/JavaTypeName.cs @@ -55,10 +55,25 @@ public static JavaTypeName Parse (string dottedFullName) ret.ArrayPart += dottedFullName.Substring (aidx); dottedFullName = dottedFullName.Substring (0, aidx); } - + + Func getMatchingGenericCloser = (str, start) => { + int count = 0; + for (int i = start; i < str.Length; i++) { + switch (str [i]) { + case '<': + count++; + break; + case '>': + if (count-- == 0) + return i; + break; + } + } + return -1; + }; int idx = dottedFullName.IndexOf ('<'); if (idx > 0) { - int last = dottedFullName.LastIndexOf ('>'); + int last = getMatchingGenericCloser (dottedFullName, idx + 1); ret.GenericArguments = ParseCommaSeparatedTypeNames (dottedFullName.Substring (idx + 1, last - idx - 1)) .Select (s => JavaTypeName.Parse (s.Trim ())) .ToArray ();