public override bool Equals(object obj) { GenericInstanceKey other = obj as GenericInstanceKey; if (other == null) { return(false); } if (gtd != other.gtd) { return(false); } for (int i = 0; i < args.Length; ++i) { Type a = args [i]; Type b = other.args [i]; /* * We must cannonicalize as much as we can. Using equals means that some resulting types * won't have the exact same types as the argument ones. * For example, flyweight types used array, pointer and byref will should this behavior. * MCS seens to be resilient to this problem so hopefully this won't show up. */ if (a != b && !a.Equals(b)) { return(false); } } return(true); }
/*Warning, @typeArguments must be a mscorlib internal array. So make a copy before passing it in*/ internal Type MakeGenericType (Type gtd, Type[] typeArguments) { if (!IsCompilerContext) return new MonoGenericClass (gtd, typeArguments); GenericInstanceKey key = new GenericInstanceKey (gtd, typeArguments); MonoGenericClass res = (MonoGenericClass)generic_instances [key]; if (res == null) { res = new MonoGenericClass (gtd, typeArguments); generic_instances [key] = res; } return res; }