private void LoadCustomAttributeMetadata() { if (!_stream.Tables.ContainsKey(MetadataTables.CustomAttribute)) { return; } MetadataRow[] customAttributes = _stream.Tables[MetadataTables.CustomAttribute]; for (int i = 0; i < customAttributes.Length; i++) { CustomAttributeMetadataTableRow customAttributeRow = customAttributes[i] as CustomAttributeMetadataTableRow; ReflectedMember attributeTo = _map.GetDefinition(customAttributeRow.Parent.Table, _stream.GetEntryFor(customAttributeRow.Parent) ); MemberRef ofType = _map.GetDefinition(customAttributeRow.Type.Table, _stream.GetEntryFor(customAttributeRow.Type) ) as MemberRef; if (attributeTo != null) { CustomAttribute attribute = new CustomAttribute(ofType); attributeTo.Attributes.Add(attribute); } } }
public CustomAttributeEntry(MetadataDirectory directory, CustomAttributeMetadataTableRow row) { this.FileOffset = string.Format("0x{0:x}", row.FileOffset); this.Parent = row.Parent.ToString(); this.Type = row.Type.ToString(); this.Value = string.Format("0x{0:x}", row.Value); }
public void CustomAttribute_WhenCreated_OffsetIsMovedOn(byte blobIndexSize, int codedIndexSize, int expected) { ICodedIndexResolver resolver = IndexHelper.CreateCodedIndexResolver(codedIndexSize); IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2, 2, blobIndexSize, 2); byte sizeOfBlobIndexes = blobIndexSize; Offset offset = 0; byte[] contents = new byte[10]; CustomAttributeMetadataTableRow row = new CustomAttributeMetadataTableRow(contents, offset, resolver, indexDetails); Assert.AreEqual(expected, offset.Current); }
public void CustomAttribute_WhenCreated_FieldsAreReadCorrectly() { ICodedIndexResolver resolver = IndexHelper.CreateCodedIndexResolver(2); IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2); byte sizeOfBlobIndexes = 2; byte[] contents = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }; CustomAttributeMetadataTableRow row = new CustomAttributeMetadataTableRow(contents, 0, resolver, indexDetails); Assert.IsNotNull(row.Parent); Assert.IsNotNull(row.Type); Assert.AreEqual(1, row.Value); }