示例#1
0
        public void DeclSecurity_WhenCreated_OffsetIsMovedOn(byte blobIndexSize, byte codedIndexSize, int expected)
        {
            byte[] content = new byte[20];
            Offset offset  = 0;
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(codedIndexSize);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2, 2, blobIndexSize, codedIndexSize);

            DeclSecurityMetadataTableRow row = new DeclSecurityMetadataTableRow(content, offset, resolver, indexDetails);

            Assert.AreEqual(expected, offset.Current);
        }
        public void GenericConstraint_WhenCreated_OffsetIsMovedOn()
        {
            byte[] contents = new byte[10];
            Offset offset   = 0;
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            GenericParamConstraintMetadataTableRow row = new GenericParamConstraintMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(4, offset.Current);
        }
        public void MemberRef_WhenCreated_OffsetIsMovedOn()
        {
            byte[] contents = new byte[10];
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);
            Offset offset = 0;

            MemberRefMetadataTableRow row = new MemberRefMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(6, offset.Current);
        }
示例#4
0
        public void FieldMarshal_WhenCreated_OffsetIsMovedOn()
        {
            byte[] contents = new byte[10];
            Offset offset   = 0;
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            FieldMarshalMetadataTableRow row = new FieldMarshalMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(4, offset.Current);
        }
示例#5
0
        public void Event_WhenCreated_MovesOffsetOn()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[20];
            Offset offset   = 0;

            EventMetadataTableRow row = new EventMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(6, offset.Current);
        }
        public void ManifestResource_WhenCreated_OffsetIsMovedOn()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[12];
            Offset offset   = 0;

            ManifestResourceMetadataTableRow row = new ManifestResourceMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(12, offset.Current);
        }
        public void ExportedType_WhenCreated_OffsetIsMovedOn()
        {
            Offset offset = 0;

            byte[] contents = new byte[20];
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            ExportedTypeMetadataTableRow row = new ExportedTypeMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(14, offset.Current);
        }
        public void Constant_WhenCreated_OffsetIsMovedOn()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);
            Offset offset = 0;

            byte[] content = new byte[30];

            ConstantMetadataTableRow row = new ConstantMetadataTableRow(content, offset, resolver, indexDetails);

            Assert.AreEqual(6, offset.Current);
        }
        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 InterfaceImpl_WhenCreated_FieldsAreReadCorrectly()
        {
            byte[] contents = new byte[] {
                0x01, 0x00,
                0x00, 0x00
            };
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            InterfaceImplMetadataTableRow row = new InterfaceImplMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(1, row.Class.Value);
            Assert.IsNotNull(row.Interface);
        }
        public void GenericConstraint_WhenCreated_ReadsFieldsCorrectly()
        {
            byte[] contents = new byte[] {
                0x01, 0x00,
                0x01, 0x00
            };
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            GenericParamConstraintMetadataTableRow row = new GenericParamConstraintMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(1, row.Owner.Value);
            Assert.IsNotNull(row.Owner);
        }
示例#12
0
        public void FieldMarshal_WhenCreated_FieldsAreReadCorrectly()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x01, 0x00,
                0x01, 0x00
            };

            FieldMarshalMetadataTableRow row = new FieldMarshalMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(1, row.NativeType);
            Assert.IsNotNull(row.Parent);
        }
        public void MethodSpec_WhenCreated_FieldsAreReadCorrectly()
        {
            ICodedIndexResolver resolver = IndexHelper.CreateCodedIndexResolver(2);

            byte[] contents = new byte[] {
                0x01, 0x00,
                0x01, 0x00
            };
            Offset        offset       = 0;
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            MethodSpecMetadataTableRow row = new MethodSpecMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.IsNotNull(row.Method);
            Assert.AreEqual(1, row.Instantiation);
        }
        public void MemberRef_WhenCreated_ReadFieldsCorrectly()
        {
            byte[] contents = new byte[] {
                0x00, 0x00,
                0x01, 0x00,
                0x02, 0x00
            };
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            MemberRefMetadataTableRow row = new MemberRefMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.IsNotNull(row.Class);
            Assert.AreEqual(1, row.Name.Value);
            Assert.AreEqual(2, row.Signiture.Value);
        }
        public void TypeRef_WhenCreated_FieldsAreReadCorrectly()
        {
            byte[] contents = new byte[] {
                0x00, 0x00,
                0x01, 0x00,
                0x02, 0x00
            };
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            Offset offset = 0;

            TypeRefMetadataTableRow row = new TypeRefMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.IsNotNull(row.ResolutionScope);
            Assert.AreEqual(1, row.Name.Value);
            Assert.AreEqual(2, row.Namespace.Value);
        }
示例#16
0
        public void DeclSecurity_WhenCreated_ValuesAreReadCorrectly()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x01, 0x00,
                0x00, 0x00,
                0x01, 0x00
            };

            DeclSecurityMetadataTableRow row = new DeclSecurityMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(1, row.PermissionSet);
            Assert.AreEqual(1, row.Action);
            Assert.IsNotNull(row.Parent);
        }
示例#17
0
        public void MethodSemantics_WhenCreated_FieldsAreReadCorrectly()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x01, 0x00,
                0x01, 0x00,
                0x00, 0x00
            };

            MethodSemanticsMetadataTableRow row = new MethodSemanticsMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(MethodSemanticsAttributes.Setter, row.Semantics);
            Assert.AreEqual(1, row.Method.Value);
            Assert.IsNotNull(row.Association);
        }
示例#18
0
        public void Event_WhenCreated_ReadValuesCorrectly()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x00, 0x02,
                0x01, 0x00,
                0x01, 0x00
            };

            EventMetadataTableRow row = new EventMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(EventAttributes.SpecialName, row.EventFlags);
            Assert.IsNotNull(row.EventType);
            Assert.AreEqual(1, row.Name.Value);
        }
        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);
        }
        public void Field_WhenCreated_FieldsAreReadCorrectly()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x06, 0x00,
                0x01, 0x00,
                0x01, 0x00
            };

            FieldMetadataTableRow row = new FieldMetadataTableRow(contents, 0, indexDetails);

            Assert.AreEqual(FieldAttributes.Public, row.Flags);
            Assert.AreEqual(1, row.Name.Value);
            Assert.AreEqual(1, row.Signiture.Value);
            Assert.AreEqual(Signatures.Field, row.Signiture.SignitureType);
        }
        public void Constant_WhenCreated_ValuesAreReadCorrectly()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] content = new byte[] {
                0x01,
                0x00,
                0x05, 0x00,
                0x00, 0x00
            };

            ConstantMetadataTableRow row = new ConstantMetadataTableRow(content, 0, resolver, indexDetails);

            Assert.AreEqual(Reflection.Signatures.ElementTypes.Void, row.Type);
            Assert.IsNotNull(row.Parent);
            Assert.AreEqual(0, row.Value.Value);
        }
        public void ManifestResource_WhenCreated_FieldsAreReadCorrectly()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x01, 0x00, 0x00, 0x00,
                0x01, 0x00, 0x00, 0x00,
                0x01, 0x00,
                0x00, 0x00
            };

            ManifestResourceMetadataTableRow row = new ManifestResourceMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(1, row.Offset);
            Assert.AreEqual(ManifestResourceAttributes.Public, row.Flags);
            Assert.AreEqual(1, row.Name.Value);
            Assert.IsNotNull(row.Implementation);
        }
        public void ImplMap_WhenCreated_FieldsAreReadCorrectly()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x01, 0x00,
                0x01, 0x00,
                0x01, 0x00,
                0x01, 0x00
            };

            ImplMapMetadataTableRow row = new ImplMapMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(PInvokeAttributes.NoMangle, row.MappingFlags);
            Assert.IsNotNull(row.MemberForward);
            Assert.AreEqual(1, row.ImportName.Value);
            Assert.AreEqual(1, row.ImportScope.Value);
        }
示例#24
0
        public void GenericParam_WhenCreated_FieldsAreReadCorrectly()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x01, 0x00,
                0x01, 0x00,
                0x01, 0x00,
                0x01, 0x00
            };

            GenericParamMetadataTableRow row = new GenericParamMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(1, row.Number);
            Assert.AreEqual(GenericParamAttributes.Covariant, row.Flags);
            Assert.IsNotNull(row.Owner);
            Assert.AreEqual(1, row.Name.Value);
        }
        public void ExportedType_WhenCreated_ReadFields()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x01, 0x00, 0x00, 0x00,
                0x05, 0x00, 0x00, 0x00,
                0x01, 0x00,
                0x01, 0x00,
                0x00, 0x00
            };

            ExportedTypeMetadataTableRow row = new ExportedTypeMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(TypeAttributes.Public, row.Flags);
            Assert.AreEqual(5, row.TypeDefId);
            Assert.AreEqual(1, row.TypeName.Value);
            Assert.AreEqual(1, row.TypeNamespace.Value);
            Assert.IsNotNull(row.Implementation);
        }
        public void TypeDef_WhenCreated_FieldsAreReadCorrectly()
        {
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x80, 0x00, 0x00, 0x00,
                0x01, 0x00,
                0x02, 0x00,
                0x05, 0x00,
                0x03, 0x00,
                0x04, 0x00
            };
            ICodedIndexResolver resolver = IndexHelper.CreateCodedIndexResolver(2);
            Offset offset = 0;

            TypeDefMetadataTableRow row = new TypeDefMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(TypeAttributes.Abstract, row.Flags);
            Assert.AreEqual(1, row.Name.Value);
            Assert.AreEqual(2, row.Namespace.Value);
            Assert.IsNotNull(row.Extends);
            Assert.AreEqual(3, row.FieldList.Value);
            Assert.AreEqual(4, row.MethodList.Value);
        }