Beispiel #1
0
        /// <summary>
        /// Returns the result of canonicalizing this method over the given kind of Canon
        /// </summary>
        public override MethodDesc GetCanonMethodTarget(CanonicalFormKind kind)
        {
            InstantiatedMethod canonicalMethodResult = GetCachedCanonValue(kind);

            if (canonicalMethodResult != null)
            {
                return(canonicalMethodResult);
            }

            MethodDesc openMethodOnCanonicalizedType = _methodDef.GetCanonMethodTarget(kind);

            // TODO: We should avoid the array allocation if conversion to canon is not change (take hint from MethodDesc.InstantiateSignature)
            Instantiation newInstantiation = CanonUtilites.ConvertInstantiationToCanonForm(Context, Instantiation, kind);

            canonicalMethodResult = Context.GetInstantiatedMethod(openMethodOnCanonicalizedType, newInstantiation);

            SetCachedCanonValue(kind, canonicalMethodResult);
            return(GetCachedCanonValue(kind));
        }
        /// <summary>
        /// Returns the result of canonicalizing this method over the given kind of Canon
        /// </summary>
        public override MethodDesc GetCanonMethodTarget(CanonicalFormKind kind)
        {
            InstantiatedMethod canonicalMethodResult = GetCachedCanonValue(kind);

            if (canonicalMethodResult == null)
            {
                bool          needsChange;
                Instantiation canonInstantiation = CanonUtilites.ConvertInstantiationToCanonForm(Instantiation, kind, out needsChange);
                if (needsChange)
                {
                    MethodDesc openMethodOnCanonicalizedType = _methodDef.GetCanonMethodTarget(kind);
                    canonicalMethodResult = Context.GetInstantiatedMethod(openMethodOnCanonicalizedType, canonInstantiation);
                }
                else
                {
                    canonicalMethodResult = this;
                }

                SetCachedCanonValue(kind, canonicalMethodResult);
            }

            return(canonicalMethodResult);
        }