Example #1
0
 public DmdParsedTypeRef(DmdModule ownerModule, DmdParsedTypeRef declaringTypeRef, DmdTypeScope typeScope, string @namespace, string name, IList <DmdCustomModifier> customModifiers) : base(ownerModule, 0, customModifiers)
 {
     this.typeScope        = typeScope;
     this.declaringTypeRef = declaringTypeRef;
     MetadataNamespace     = @namespace;
     MetadataName          = name ?? throw new ArgumentNullException(nameof(name));
 }
        public DmdExportedTypeCOMD(DmdComMetadataReader reader, uint rid, IList <DmdCustomModifier> customModifiers) : base(reader.Module, rid, customModifiers)
        {
            this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
            reader.Dispatcher.VerifyAccess();

            uint token = 0x27000000 + rid;

            DmdTypeUtilities.SplitFullName(MDAPI.GetExportedTypeName(reader.MetaDataAssemblyImport, token) ?? string.Empty, out var @namespace, out var name);
            MetadataNamespace = @namespace;
            MetadataName      = name;

            MDAPI.GetExportedTypeProps(reader.MetaDataAssemblyImport, token, out var implToken, out _, out _);
            switch (implToken >> 24)
            {
            case 0x23:
                TypeScope = new DmdTypeScope(reader.ReadAssemblyName_COMThread(implToken & 0x00FFFFFF));
                break;

            case 0x26:
                var moduleName = MDAPI.GetFileName(reader.MetaDataAssemblyImport, implToken) ?? string.Empty;
                TypeScope = new DmdTypeScope(reader.GetName(), moduleName);
                break;

            case 0x27:
                TypeScope     = DmdTypeScope.Invalid;
                baseTypeToken = (int)implToken;
                break;

            default:
                TypeScope = DmdTypeScope.Invalid;
                break;
            }
        }
Example #3
0
        public DmdTypeRefMD(DmdEcma335MetadataReader reader, uint rid, IList <DmdCustomModifier> customModifiers) : base(reader.Module, rid, customModifiers)
        {
            this.reader = reader ?? throw new ArgumentNullException(nameof(reader));

            bool b = reader.TablesStream.TryReadTypeRefRow(rid, out var row);

            Debug.Assert(b);
            var ns = reader.StringsStream.Read(row.Namespace);

            MetadataNamespace = string.IsNullOrEmpty(ns) ? null : ns;
            MetadataName      = reader.StringsStream.ReadNoNull(row.Name);

            if (!CodedToken.ResolutionScope.Decode(row.ResolutionScope, out uint resScopeToken))
            {
                resScopeToken = uint.MaxValue;
            }
            switch (resScopeToken >> 24)
            {
            case 0x00:
                TypeScope = new DmdTypeScope(reader.Module);
                break;

            case 0x01:
                TypeScope     = DmdTypeScope.Invalid;
                declTypeToken = (int)resScopeToken;
                break;

            case 0x1A:
                reader.TablesStream.TryReadModuleRefRow(resScopeToken & 0x00FFFFFF, out var moduleRefRow);
                var moduleName = reader.StringsStream.ReadNoNull(moduleRefRow.Name);
                TypeScope = new DmdTypeScope(reader.GetName(), moduleName);
                break;

            case 0x23:
                TypeScope = new DmdTypeScope(reader.ReadAssemblyName(resScopeToken & 0x00FFFFFF));
                break;

            default:
                TypeScope = DmdTypeScope.Invalid;
                break;
            }
        }
        public DmdExportedTypeMD(DmdEcma335MetadataReader reader, uint rid, IList <DmdCustomModifier> customModifiers) : base(reader.Module, rid, customModifiers)
        {
            this.reader = reader ?? throw new ArgumentNullException(nameof(reader));

            bool b = reader.TablesStream.TryReadExportedTypeRow(rid, out var row);

            Debug.Assert(b);
            var ns = reader.StringsStream.Read(row.TypeNamespace);

            MetadataNamespace = string.IsNullOrEmpty(ns) ? null : ns;
            MetadataName      = reader.StringsStream.ReadNoNull(row.TypeName);

            if (!CodedToken.Implementation.Decode(row.Implementation, out uint implToken))
            {
                implToken = uint.MaxValue;
            }
            switch (implToken >> 24)
            {
            case 0x23:
                TypeScope = new DmdTypeScope(reader.ReadAssemblyName(implToken & 0x00FFFFFF));
                break;

            case 0x26:
                reader.TablesStream.TryReadFileRow(implToken & 0x00FFFFFF, out var fileRow);
                var moduleName = reader.StringsStream.ReadNoNull(fileRow.Name);
                TypeScope = new DmdTypeScope(reader.GetName(), moduleName);
                break;

            case 0x27:
                TypeScope     = DmdTypeScope.Invalid;
                baseTypeToken = (int)implToken;
                break;

            default:
                TypeScope = DmdTypeScope.Invalid;
                break;
            }
        }
Example #5
0
        public DmdTypeRefCOMD(DmdComMetadataReader reader, uint rid, IList <DmdCustomModifier> customModifiers) : base(reader.Module, rid, customModifiers)
        {
            this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
            reader.Dispatcher.VerifyAccess();
            uint token = 0x01000000 + rid;

            DmdTypeUtilities.SplitFullName(MDAPI.GetTypeRefName(reader.MetaDataImport, token) ?? string.Empty, out var @namespace, out var name);
            MetadataNamespace = @namespace;
            MetadataName      = name;

            var resScopeToken = MDAPI.GetTypeRefResolutionScope(reader.MetaDataImport, token);

            switch (resScopeToken >> 24)
            {
            case 0x00:
                TypeScope = new DmdTypeScope(reader.Module);
                break;

            case 0x01:
                TypeScope     = DmdTypeScope.Invalid;
                declTypeToken = (int)resScopeToken;
                break;

            case 0x1A:
                var moduleName = MDAPI.GetModuleRefName(reader.MetaDataImport, resScopeToken) ?? string.Empty;
                TypeScope = new DmdTypeScope(reader.GetName(), moduleName);
                break;

            case 0x23:
                TypeScope = new DmdTypeScope(reader.ReadAssemblyName_COMThread(resScopeToken & 0x00FFFFFF));
                break;

            default:
                TypeScope = DmdTypeScope.Invalid;
                break;
            }
        }
Example #6
0
 internal void SetTypeScope(DmdTypeScope typeScope) => this.typeScope = typeScope;