private static void ValidateArity(CodeTypeReference e) {
// Verify that the number of TypeArguments agrees with the arity on the type.
string baseType = e.BaseType;
int totalTypeArgs = 0;
for (int i=0; i<baseType.Length; i++) {
if (baseType[i] == '`') {
i++; // skip the '
int numTypeArgs = 0;
while (i < baseType.Length && baseType[i] >= '0' && baseType[i] <='9') {
numTypeArgs = numTypeArgs*10 + (baseType[i] - '0');
i++;
}
totalTypeArgs += numTypeArgs;
}
}
// Check if we have zero type args for open types.
if ((totalTypeArgs != e.TypeArguments.Count) && (e.TypeArguments.Count != 0)) {
throw new ArgumentException(SR.GetString(SR.ArityDoesntMatch, baseType, e.TypeArguments.Count));
}
}