Mono.AssemblyLocationProvider.RemoveGenerics C# (CSharp) Method

RemoveGenerics() static private method

static private RemoveGenerics ( string expected, char open, char close ) : string
expected string
open char
close char
return string
		static string RemoveGenerics (string expected, char open, char close)
		{
			if (expected.IndexOf (open) < 0)
				return expected;

			var sb = new StringBuilder ();
			for (int i = 0; i < expected.Length;) {
				int start = expected.IndexOf (open, i);
				int end = expected.IndexOf (close, i);
				if (start < 0 || end < 0) {
					sb.Append (expected, i, expected.Length - i);
					break;
				}

				bool is_ginst = false;
				for (int j = start + 1; j < end; ++j) {
					if (expected [j] != ',')
						is_ginst = true;
				}

				if (is_ginst) //discard the the generic args
					sb.Append (expected, i, start - i);
				else //include array arity
					sb.Append (expected, i, end + 1 - i);
				i = end + 1;

			}
			return sb.ToString ();
		}