Esempio n. 1
0
            public TypeDefBuilder(BuildReferences references, TypeDefMetadataTableRow fromRow)
            {
                _references = references;

                _assembly       = references.Assembly;
                _fromRow        = fromRow;
                _metadata       = references.Metadata;
                _map            = references.Map;
                _metadataStream = _metadata.GetMetadataStream();
            }
        /// <summary>
        /// Initialises and populates a new GenericTypeRef instance based on the details
        /// provided in the metadata row.
        /// </summary>
        /// <param name="references">All the required references the create requires to build the type.</param>
        /// <param name="fromRow">The metadata row.</param>
        /// <returns>The populated instance.</returns>
        internal static GenericTypeRef CreateFromMetadata(BuildReferences references, GenericParamMetadataTableRow fromRow)
        {
            GenericTypeRef genericType = new GenericTypeRef();

            genericType.UniqueId = references.Assembly.CreateUniqueId();
            genericType.Sequence = (short)fromRow.Number;
            genericType.Name     = references.Assembly.StringStream.GetString(fromRow.Name.Value);
            // this.Flags = FieldReader.ToUInt16(contents, offset.Shift(2));

            return(genericType);
        }
Esempio n. 3
0
            public MethodDefBuilder(BuildReferences references, TypeDef container, MethodMetadataTableRow fromRow)
            {
                _metadata       = references.Metadata;
                _map            = references.Map;
                _assembly       = references.Assembly;
                _container      = container;
                _fromRow        = fromRow;
                _metadataStream = _metadata.Streams[Streams.MetadataStream] as MetadataStream;
                _blobStream     = _metadata.Streams[Streams.BlobStream] as BlobStream;

                _references = references;
            }
Esempio n. 4
0
        /// <summary>
        /// Initialises a new instance of the AssemblyRef class from the provided details.
        /// </summary>
        /// <param name="references">Container of all the references required to build this type.</param>
        /// <param name="row">The row that provides the assembly reference details.</param>
        /// <returns>A populated AssemblyRef instance.</returns>
        internal static AssemblyRef CreateFromMetadata(BuildReferences references, AssemblyRefMetadataTableRow row)
        {
            AssemblyRef assemblyRef = new AssemblyRef();

            assemblyRef.Version = new Version(
                row.MajorVersion,
                row.MinorVersion,
                row.BuildNumber,
                row.RevisionNumber);
            assemblyRef.Culture  = references.Assembly.StringStream.GetString(row.Culture.Value);
            assemblyRef.UniqueId = references.Assembly.CreateUniqueId();
            assemblyRef.Name     = references.Assembly.StringStream.GetString(row.Name.Value);
            assemblyRef.Assembly = references.Assembly;

            return(assemblyRef);
        }
        public AssemblyDefBuilder(PeCoffFile peCoffFile)
        {
            if (peCoffFile == null)
            {
                throw new ArgumentNullException(nameof(peCoffFile));
            }
            if (!peCoffFile.Directories.ContainsKey(DataDirectories.CommonLanguageRuntimeHeader))
            {
                throw new NotAManagedLibraryException($"The file '{peCoffFile.FileName}' is not a managed library.");
            }

            _peCoffFile = peCoffFile;
            _map        = _peCoffFile.Map;

            _references            = new BuildReferences();
            _references.Map        = _map;
            _references.PeCoffFile = _peCoffFile;
            _references.Metadata   = _peCoffFile.GetMetadataDirectory();
        }
Esempio n. 6
0
        internal static TypeDef CreateFromMetadata(BuildReferences references, TypeDefMetadataTableRow fromRow)
        {
            TypeDefBuilder builder = new TypeDefBuilder(references, fromRow);

            return(builder.Build());
        }
Esempio n. 7
0
        /// <summary>
        /// Initialises a new instance of MethodDef for the provided data
        /// </summary>
        /// <param name="references">The references required to build the methods</param>
        /// <param name="container">The owning type for this method</param>
        /// <param name="row">The row detailing the method</param>
        /// <returns>The initialised MethodDef</returns>
        internal static MethodDef CreateFromMetadata(BuildReferences references, TypeDef container, MethodMetadataTableRow row)
        {
            MethodDefBuilder builder = new MethodDefBuilder(references, container, row);

            return(builder.Build());
        }