public override void Visit(ITypeExport aliasForType) { this.Visit(aliasForType.GetAttributes(Context)); // do not visit the reference to aliased type, it does not get into the type ref table based only on its membership of the exported types collection. // but DO visit the reference to assembly (if any) that defines the aliased type. That assembly might not already be in the assembly reference list. var definingUnit = PeWriter.GetDefiningUnitReference(aliasForType.ExportedType, Context); var definingAssembly = definingUnit as IAssemblyReference; if (definingAssembly != null) { this.Visit(definingAssembly); } var definingModule = definingUnit as IModuleReference; if (definingModule != null) { definingAssembly = definingModule.GetContainingAssembly(Context); if (definingAssembly != null && !ReferenceEquals(definingAssembly, this.module.GetContainingAssembly(Context))) { this.Visit(definingAssembly); } } }
public override void Visit(IMethodReference methodReference) { IGenericMethodInstanceReference genericMethodInstanceReference = methodReference.AsGenericMethodInstanceReference; if (genericMethodInstanceReference != null) { this.Visit(genericMethodInstanceReference); return; } if (!alreadySeen.Add(methodReference)) { return; } // If we have a ref to a varargs method then we always generate an entry in the MethodRef table, // even if it is a method in the current module. (Note that we are not *required* to do so if // in fact the number of extra arguments passed is zero; in that case we are permitted to use // an ordinary method def token. We consistently choose to emit a method ref regardless.) IUnitReference definingUnit = PeWriter.GetDefiningUnitReference(methodReference.GetContainingType(Context), Context); if (definingUnit != null && ReferenceEquals(definingUnit, this.module) && !methodReference.AcceptsExtraArguments) { return; } this.Visit((ITypeMemberReference)methodReference); ISpecializedMethodReference specializedMethodReference = methodReference.AsSpecializedMethodReference; if (specializedMethodReference != null) { IMethodReference unspecializedMethodReference = specializedMethodReference.UnspecializedVersion; this.Visit(unspecializedMethodReference.GetType(Context)); this.Visit(unspecializedMethodReference.GetParameters(Context)); this.Visit(unspecializedMethodReference.ReturnValueCustomModifiers); } else { this.Visit(methodReference.GetType(Context)); this.Visit(methodReference.GetParameters(Context)); this.Visit(methodReference.ReturnValueCustomModifiers); } if (methodReference.AcceptsExtraArguments) { this.Visit(methodReference.ExtraParameters); } ReserveMethodToken(methodReference); }
public override void Visit(IFieldReference fieldReference) { if (!alreadySeen.Add(fieldReference)) { return; } IUnitReference /*?*/ definingUnit = PeWriter.GetDefiningUnitReference(fieldReference.GetContainingType(Context), Context); if (definingUnit != null && ReferenceEquals(definingUnit, this.module)) { return; } this.Visit((ITypeMemberReference)fieldReference); this.Visit(fieldReference.GetType(Context)); ReserveFieldToken(fieldReference); }