コード例 #1
0
ファイル: TypeSystemHelpers.cs プロジェクト: cdxntchou/corert
        /// <summary>
        /// Creates an open instantiation of a method. Given Foo&lt;T&gt;.Method, returns
        /// Foo&lt;!0&gt;.Method. If the owning type is not generic, returns the <paramref name="method"/>.
        /// </summary>
        public static MethodDesc InstantiateAsOpen(this MethodDesc method)
        {
            Debug.Assert(method.IsMethodDefinition && !method.HasInstantiation);

            TypeDesc owner = method.OwningType;

            if (owner.HasInstantiation)
            {
                MetadataType instantiatedOwner = (MetadataType)owner.InstantiateAsOpen();
                return(method.Context.GetMethodForInstantiatedType(method, (InstantiatedType)instantiatedOwner));
            }

            return(method);
        }
コード例 #2
0
ファイル: TypeSystemHelpers.cs プロジェクト: cdxntchou/corert
        /// <summary>
        /// Creates an open instantiation of a field. Given Foo&lt;T&gt;.Field, returns
        /// Foo&lt;!0&gt;.Field. If the owning type is not generic, returns the <paramref name="field"/>.
        /// </summary>
        public static FieldDesc InstantiateAsOpen(this FieldDesc field)
        {
            Debug.Assert(field.GetTypicalFieldDefinition() == field);

            TypeDesc owner = field.OwningType;

            if (owner.HasInstantiation)
            {
                var instantiatedOwner = (InstantiatedType)owner.InstantiateAsOpen();
                return(field.Context.GetFieldForInstantiatedType(field, instantiatedOwner));
            }

            return(field);
        }