private void LoadParameters()
            {
                MetadataTablesDictionary tables = _metadataStream.Tables;

                if (tables.ContainsKey(MetadataTables.Param))
                {
                    for (int i = _fromRow.ParamList; i < _endOfMethodIndex; i++)
                    {
                        ParamMetadataTableRow metadataRow = tables[MetadataTables.Param][i - 1] as ParamMetadataTableRow;

                        ParamDef param = new ParamDef(
                            _references.Assembly.StringStream.GetString(metadataRow.Name.Value),
                            _methodToBuild,
                            metadataRow.Sequence,
                            _references.Assembly,
                            metadataRow.Flags
                            );

                        //ParamDef param = new ParamDef(_references, _methodToBuild, metadataRow);

                        _map.Add(MetadataTables.Param, metadataRow, param);
                        _methodToBuild.Parameters.Add(param);
                    }
                }

                if (_methodToBuild.IsSpecialName && _methodToBuild.Name.Contains("set_Item"))
                {
                    // for setter methods on indexers the last parameter is actually the return value
                    _methodToBuild.Parameters.RemoveAt(_methodToBuild.Parameters.Count - 1);
                }
            }
Exemple #2
0
 public ParamEntry(int index, MetadataDirectory directory, ParamMetadataTableRow row)
 {
     this.Index      = index;
     this.FileOffset = string.Format("0x{0:x}", row.FileOffset);
     this.Name       = ((StringStream)directory.Streams[Streams.StringStream]).GetString(row.Name.Value);
     this.Sequence   = row.Sequence.ToString();
     this.Flags      = string.Format("0x{0:x}", row.Flags);
 }
Exemple #3
0
        public void Param_WhenCreated_OffsetIsMovedOn()
        {
            byte[] contents = new byte[6];
            Offset offset   = 0;

            ParamMetadataTableRow row = new ParamMetadataTableRow(contents, offset, 2);

            Assert.AreEqual(6, offset.Current);
        }
Exemple #4
0
        public void Param_WhenCreated_FieldsAreReadCorrectly()
        {
            byte[] contents = new byte[] {
                0x01, 0x00,
                0x03, 0x00,
                0x02, 0x00
            };
            Offset offset = 0;

            ParamMetadataTableRow row = new ParamMetadataTableRow(contents, offset, 2);

            Assert.AreEqual(ParamAttributeFlags.In, row.Flags);
            Assert.AreEqual(3, row.Sequence);
            Assert.AreEqual(2, row.Name.Value);
        }