public ModuleDef(string name, AssemblyDef definingAssembly, Guid moduleVersionId)
 {
     Name = name;
     Assembly = definingAssembly;
     UniqueId = definingAssembly.CreateUniqueId();
     _moduleVersionId = moduleVersionId;
 }
Exemple #2
0
 /// <summary>
 /// Constructs a ParamDef with the provided details.
 /// </summary>
 /// <param name="name">The name for the parameter</param>
 /// <param name="container">The method that defines and contains the parameter</param>
 /// <param name="sequence">The sequence in the parameter list for this parameter</param>
 /// <param name="definingAssembly">The assembly in which the parameter is defined</param>
 /// <param name="flags">The attribute flags for the parameter</param>
 public ParamDef(string name, MethodDef container, int sequence, AssemblyDef definingAssembly, ParamAttributeFlags flags)
 {
     _constants = new List <ConstantInfo>();
     _method    = container;
     _sequence  = sequence;
     _flags     = flags;
     UniqueId   = definingAssembly.CreateUniqueId();
     Assembly   = definingAssembly;
     Name       = name;
 }
Exemple #3
0
 public FieldDef(string name, AssemblyDef definingAssembly, TypeDef containingType, FieldAttributes attributes, BlobIndex signitureIndex)
 {
     UniqueId      = definingAssembly.CreateUniqueId();
     Assembly      = definingAssembly;
     Type          = containingType;
     Name          = name;
     SignitureBlob = signitureIndex;
     _flags        = attributes;
     _constants    = new List <ConstantInfo>();
 }
Exemple #4
0
 /// <summary>
 /// Initiliases a new instance of the TypeRef class using the provided details.
 /// </summary>
 /// <param name="definingAssembly">The assembly which defines the type reference</param>
 /// <param name="name">The name of the type reference</param>
 /// <param name="namespaceName">The namespace it is defined in</param>
 /// <param name="resolutionScope">A CodedIndex determining the resolve the external reference</param>
 public TypeRef(AssemblyDef definingAssembly, string name, string namespaceName, CodedIndex resolutionScope)
 {
     UniqueId             = definingAssembly.CreateUniqueId();
     Assembly             = definingAssembly;
     Name                 = name;
     Namespace            = namespaceName;
     _isExternalReference = true;
     _resolutionScope     = resolutionScope;
     _isGeneric           = name.IndexOf('`') != -1;
     _extensionMethods    = new List <MethodDef>();
 }
            private void SetTypeProperties()
            {
                int index = _metadataStream.Tables.GetIndexFor(MetadataTables.TypeDef, _fromRow);

                _builtType._index = index + 1;
                _builtType._table = MetadataTables.TypeDef;

                _builtType.UniqueId  = _assembly.CreateUniqueId();
                _builtType.Name      = _assembly.StringStream.GetString(_fromRow.Name.Value);
                _builtType.Namespace = _assembly.StringStream.GetString(_fromRow.Namespace.Value);
                _builtType.Assembly  = _assembly;
                _builtType._extends  = _fromRow.Extends;
                _builtType.Flags     = _fromRow.Flags;
                _builtType.IsGeneric = _builtType.Name.Contains("`"); // Should be quicker then checking the genparam table
            }
Exemple #6
0
        /// <summary>
        /// Factor method for instantiating and populating MemberRef instances from
        /// Metadata.
        /// </summary>
        /// <param name="assembly">The assembly the reference is defined in.</param>
        /// <param name="metadata">The metadata the reference is detailed in.</param>
        /// <param name="row">The actual metadata row with the details of the member.</param>
        /// <returns>An instantiated MemberRef instance.</returns>
        internal static MemberRef CreateFromMetadata(
            AssemblyDef assembly,
            MetadataDirectory metadata,
            MemberRefMetadataTableRow row)
        {
            MemberRef memberRef = new MemberRef();

            memberRef.UniqueId      = assembly.CreateUniqueId();
            memberRef.Name          = assembly.StringStream.GetString(row.Name.Value);
            memberRef.SignitureBlob = row.Signiture;
            memberRef.Assembly      = assembly;
            memberRef._class        = row.Class;

            // These methods of detecting different method types are not
            // infalable. A user can create a method for example that starts iwth
            // get_, set_ or op_. This best detail is stored in the MethodSemantics
            // table AND we will need to load that at some point :/
            memberRef.IsConstructor = memberRef.Name.StartsWith(".");
            memberRef.IsOperator    = memberRef.Name.StartsWith("op_");

            return(memberRef);
        }
            private void SetMethodProperties()
            {
                _methodToBuild.GenericTypes  = new List <GenericTypeRef>();
                _methodToBuild.Parameters    = new List <ParamDef>();
                _methodToBuild.UniqueId      = _assembly.CreateUniqueId();
                _methodToBuild.Assembly      = _assembly;
                _methodToBuild.Type          = _container;
                _methodToBuild._rva          = _fromRow.RVA;
                _methodToBuild.Name          = _assembly.StringStream.GetString(_fromRow.Name.Value);
                _methodToBuild.SignitureBlob = _fromRow.Signiture;
                // Set flag based information
                _methodToBuild._attributes          = _fromRow.Flags;
                _methodToBuild._implementationFlags = _fromRow.ImplFlags;
                _methodToBuild.Assembly             = _assembly;

                // See details of MemberRef implementation for issues with this!
                if (_methodToBuild.Name.Length > 0)
                {
                    _methodToBuild.IsConstructor = _methodToBuild.Name[0] == '.';
                    _methodToBuild.IsOperator    = !_methodToBuild.IsConstructor && _methodToBuild.Name.StartsWith("op_");
                }
            }
 /// <summary>
 /// Creates a new instance of the TypeSpec class using the provided information.
 /// </summary>
 /// <param name="definingAssembly">The assembly which defines the type specification</param>
 /// <param name="signitureIndex">The index in to the blod where the signiture for this type is defined.</param>
 public TypeSpec(AssemblyDef definingAssembly, BlobIndex signitureIndex)
 {
     UniqueId = definingAssembly.CreateUniqueId();
     Assembly = definingAssembly;
     _signitureIndexInBlob = signitureIndex;
 }