internal TypeRefRow this[uint rowId] // This is 1 based... { get //^ requires rowId > 0 && rowId <= this.NumberOfRows; { int rowOffset = (int)(rowId - 1) * this.RowSize; uint resolutionScope = this.TypeRefTableMemoryReader.PeekReference(rowOffset + this.ResolutionScopeOffset, this.IsResolutionScopeRefSizeSmall); resolutionScope = ResolutionScopeTag.ConvertToToken(resolutionScope); uint name = this.TypeRefTableMemoryReader.PeekReference(rowOffset + this.NameOffset, this.IsStringHeapRefSizeSmall); uint @namespace = this.TypeRefTableMemoryReader.PeekReference(rowOffset + this.NamespaceOffset, this.IsStringHeapRefSizeSmall); TypeRefRow typeRefRow = new TypeRefRow(resolutionScope, name, @namespace); return typeRefRow; } }
//^ invariant this.PEFileReader.TypeSpecTable.NumberOfRows >= 1 ==> this.ModuleTypeSpecHashtable != null; TypeRefReference CreateTypeRefReference( uint typeRefRowId, TypeRefRow typeRefRow, IMetadataReaderNamedTypeReference/*?*/ parentModuleTypeReference, IMetadataReaderModuleReference moduleReference, MetadataReaderSignatureTypeCode signatureTypeCode ) { IName mangledTypeName = this.GetNameFromOffset(typeRefRow.Name); ushort genericParamCount; string typeName; TypeCache.SplitMangledTypeName(mangledTypeName.Value, out typeName, out genericParamCount); TypeRefReference moduleTypeRefReference; if (parentModuleTypeReference == null) { IName namespaceFullName = this.GetNameFromOffset(typeRefRow.Namespace); NamespaceReference namespaceReference = this.GetNamespaceReferenceForString(moduleReference, namespaceFullName); if (genericParamCount == 0) { if (signatureTypeCode == MetadataReaderSignatureTypeCode.NotModulePrimitive) { moduleTypeRefReference = new NamespaceTypeRefReferenceWithoutPrimitiveTypeCode( this, mangledTypeName, typeRefRowId, moduleReference, namespaceReference, signatureTypeCode == MetadataReaderSignatureTypeCode.ValueType ); } else { moduleTypeRefReference = new NamespaceTypeRefReferenceWithPrimitiveTypeCode( this, mangledTypeName, typeRefRowId, moduleReference, namespaceReference, signatureTypeCode ); } } else { IName iTypeName = this.NameTable.GetNameFor(typeName); moduleTypeRefReference = new GenericNamespaceTypeRefReference( this, iTypeName, typeRefRowId, moduleReference, namespaceReference, mangledTypeName, genericParamCount, signatureTypeCode == MetadataReaderSignatureTypeCode.ValueType ); } } else { if (genericParamCount == 0) { moduleTypeRefReference = new NonGenericNestedTypeRefReference( this, mangledTypeName, typeRefRowId, moduleReference, parentModuleTypeReference, signatureTypeCode == MetadataReaderSignatureTypeCode.ValueType ); } else { IName iTypeName = this.NameTable.GetNameFor(typeName); moduleTypeRefReference = new GenericNestedTypeRefReference( this, iTypeName, typeRefRowId, moduleReference, parentModuleTypeReference, mangledTypeName, genericParamCount, signatureTypeCode == MetadataReaderSignatureTypeCode.ValueType ); } } return moduleTypeRefReference; }