/// <summary> /// Creates an open instantiation of a method. Given Foo<T>.Method, returns /// Foo<!0>.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); }
/// <summary> /// Creates an open instantiation of a field. Given Foo<T>.Field, returns /// Foo<!0>.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); }