示例#1
0
        public void Equality()
        {
            var id1  = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false);
            var id11 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false);
            var id2  = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id22 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);

            var id3 = new AssemblyIdentity("Foo!", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id4 = new AssemblyIdentity("Foo", new Version(1, 0, 1, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id5 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "en-US", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id6 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", default(ImmutableArray <byte>), hasPublicKey: false, isRetargetable: false);
            var id7 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: true, isRetargetable: false);
            var id8 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: true);

            var win1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);
            var win2 = new AssemblyIdentity("Bar", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);
            var win3 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);

            Assert.True(id1.Equals(id1));
            Assert.True(id1.Equals(id2));
            Assert.True(id2.Equals(id1));
            Assert.True(id1.Equals(id11));
            Assert.True(id11.Equals(id1));
            Assert.True(id2.Equals(id22));
            Assert.True(id22.Equals(id2));

            Assert.False(id1.Equals(id3));
            Assert.False(id1.Equals(id4));
            Assert.False(id1.Equals(id5));
            Assert.False(id1.Equals(id6));
            Assert.False(id1.Equals(id7));
            Assert.False(id1.Equals(id8));

            Assert.Equal((object)id1, id1);
            Assert.NotNull(id1);
            Assert.False(id2.Equals((AssemblyIdentity)null));

            Assert.Equal(id1.GetHashCode(), id2.GetHashCode());

            Assert.False(win1.Equals(win2));
            Assert.False(win1.Equals(id1));
            Assert.True(win1.Equals(win3));

            Assert.Equal(win1.GetHashCode(), win3.GetHashCode());
        }
        public void Equality()
        {
            var id1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false);
            var id11 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false);
            var id2 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id22 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);

            var id3 = new AssemblyIdentity("Foo!", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id4 = new AssemblyIdentity("Foo", new Version(1, 0, 1, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id5 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "en-US", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var id6 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", default(ImmutableArray<byte>), hasPublicKey: false, isRetargetable: false);
            var id7 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: true, isRetargetable: false);
            var id8 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: true);

            var win1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);
            var win2 = new AssemblyIdentity("Bar", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);
            var win3 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime);

            Assert.True(id1.Equals(id1));
            Assert.True(id1.Equals(id2));
            Assert.True(id2.Equals(id1));
            Assert.True(id1.Equals(id11));
            Assert.True(id11.Equals(id1));
            Assert.True(id2.Equals(id22));
            Assert.True(id22.Equals(id2));

            Assert.False(id1.Equals(id3));
            Assert.False(id1.Equals(id4));
            Assert.False(id1.Equals(id5));
            Assert.False(id1.Equals(id6));
            Assert.False(id1.Equals(id7));
            Assert.False(id1.Equals(id8));

            Assert.Equal((object)id1, id1);
            Assert.NotNull(id1);
            Assert.False(id2.Equals((AssemblyIdentity)null));

            Assert.Equal(id1.GetHashCode(), id2.GetHashCode());

            Assert.False(win1.Equals(win2));
            Assert.False(win1.Equals(id1));
            Assert.True(win1.Equals(win3));

            Assert.Equal(win1.GetHashCode(), win3.GetHashCode());
        }
示例#3
0
        public void Equality_InvariantCulture()
        {
            var neutral1  = new AssemblyIdentity("Goo", new Version(1, 0, 0, 0), "NEUtral", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var neutral2  = new AssemblyIdentity("Goo", new Version(1, 0, 0, 0), null, RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var neutral3  = new AssemblyIdentity("Goo", new Version(1, 0, 0, 0), "neutral", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var invariant = new AssemblyIdentity("Goo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);

            Assert.True(neutral1.Equals(invariant));
            Assert.True(neutral2.Equals(invariant));
            Assert.True(neutral3.Equals(invariant));
        }
示例#4
0
        public void Equality_InvariantCulture()
        {
            var neutral1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "NEUtral", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var neutral2 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), null, RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var neutral3 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "neutral", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);
            var invariant = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false);

            Assert.True(neutral1.Equals(invariant));
            Assert.True(neutral2.Equals(invariant));
            Assert.True(neutral3.Equals(invariant));
        }
示例#5
0
        protected override int GetIndexOfReferencedAssembly(AssemblyIdentity identity)
        {
            var assemblies = this.moduleSymbol.GetReferencedAssemblySymbols();

            for (int i = 0; i < assemblies.Length; i++)
            {
                if (identity.Equals(assemblies[i].Identity))
                {
                    return(i);
                }
            }
            return(-1);
        }
        public bool Equals(MissingAssemblySymbol other)
        {
            if ((object)other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(identity.Equals(other.Identity));
        }
示例#7
0
        public bool Equals(MissingAssemblySymbol other, SymbolEqualityComparer _)
        {
            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(identity.Equals(other.Identity));
        }
示例#8
0
        private Assembly TryGetAssemblyLoadedFromPath(AssemblyIdentity identity, string directory)
        {
            string pathWithoutExtension = Path.Combine(directory, identity.Name);

            foreach (var extension in RuntimeMetadataReferenceResolver.AssemblyExtensions)
            {
                if (_assembliesLoadedFromLocationByFullPath.TryGetValue(pathWithoutExtension + extension, out var assemblyAndLocation) &&
                    identity.Equals(AssemblyIdentity.FromAssemblyDefinition(assemblyAndLocation.Assembly)))
                {
                    return(assemblyAndLocation.Assembly);
                }
            }

            return(null);
        }
示例#9
0
        private static NamedTypeSymbol GetTopLevelTypeByMetadataName(AssemblySymbol assembly, ref MetadataTypeName metadataName, AssemblyIdentity assemblyOpt)
        {
            var result = assembly.LookupTopLevelMetadataType(ref metadataName, digThroughForwardedTypes: false);
            if (!IsAcceptableMatchForGetTypeByMetadataName(result))
            {
                return null;
            }

            if (assemblyOpt != null && !assemblyOpt.Equals(assembly.Identity))
            {
                return null;
            }

            return result;
        }
示例#10
0
        protected override int GetIndexOfReferencedAssembly(AssemblyIdentity identity)
        {
            // Go through all assemblies referenced by the current module and
            // find the one which *exactly* matches the given identity.
            // No unification will be performed
            var assemblies = this.moduleSymbol.GetReferencedAssemblies();

            for (int i = 0; i < assemblies.Length; i++)
            {
                if (identity.Equals(assemblies[i]))
                {
                    return(i);
                }
            }
            return(-1);
        }
示例#11
0
        public static async Task <CodeAction> CreateAsync(Project project, AssemblyIdentity missingAssemblyIdentity, CancellationToken cancellationToken)
        {
            var dependencyGraph = project.Solution.GetProjectDependencyGraph();

            // We want to find a project that generates this assembly, if one so exists. We therefore
            // search all projects that our project with an error depends on. We want to do this for
            // complicated and evil scenarios like this one:
            //
            //     C -> B -> A
            //
            //     A'
            //
            // Where, for some insane reason, A and A' are two projects that both emit an assembly
            // by the same name. So imagine we are using a type in B from C, and we are missing a
            // reference to A.dll. Both A and A' are candidates, but we know we can throw out A'
            // since whatever type from B we are using that's causing the error, we know that type
            // isn't referencing A'. Put another way: this code action adds a reference, but should
            // never change the transitive closure of project references that C has.
            //
            // Doing this filtering also means we get to check less projects (good), and ensures that
            // whatever project reference we end up adding won't add a circularity (also good.)
            foreach (var candidateProjectId in dependencyGraph.GetProjectsThatThisProjectTransitivelyDependsOn(project.Id))
            {
                var candidateProject = project.Solution.GetRequiredProject(candidateProjectId);
                if (candidateProject.SupportsCompilation &&
                    string.Equals(missingAssemblyIdentity.Name, candidateProject.AssemblyName, StringComparison.OrdinalIgnoreCase))
                {
                    // The name matches, so let's see if the full identities are equal.
                    var compilation = await candidateProject.GetRequiredCompilationAsync(cancellationToken).ConfigureAwait(false);

                    if (missingAssemblyIdentity.Equals(compilation.Assembly.Identity))
                    {
                        // It matches, so just add a reference to this
                        return(new AddMissingReferenceCodeAction(project,
                                                                 string.Format(FeaturesResources.Add_project_reference_to_0, candidateProject.Name),
                                                                 new ProjectReference(candidateProjectId), missingAssemblyIdentity));
                    }
                }
            }

            // No matching project, so metadata reference
            var description = string.Format(FeaturesResources.Add_reference_to_0, missingAssemblyIdentity.GetDisplayName());

            return(new AddMissingReferenceCodeAction(project, description, null, missingAssemblyIdentity));
        }
        public static async Task<CodeAction> CreateAsync(Project project, AssemblyIdentity missingAssemblyIdentity, CancellationToken cancellationToken)
        {
            var dependencyGraph = project.Solution.GetProjectDependencyGraph();

            // We want to find a project that generates this assembly, if one so exists. We therefore 
            // search all projects that our project with an error depends on. We want to do this for
            // complicated and evil scenarios like this one:
            //
            //     C -> B -> A
            //
            //     A'
            //
            // Where, for some insane reason, A and A' are two projects that both emit an assembly 
            // by the same name. So imagine we are using a type in B from C, and we are missing a 
            // reference to A.dll. Both A and A' are candidates, but we know we can throw out A'
            // since whatever type from B we are using that's causing the error, we know that type 
            // isn't referencing A'. Put another way: this code action adds a reference, but should 
            // never change the transitive closure of project references that C has.
            //
            // Doing this filtering also means we get to check less projects (good), and ensures that
            // whatever project reference we end up adding won't add a circularity (also good.)
            foreach (var candidateProjectId in dependencyGraph.GetProjectsThatThisProjectTransitivelyDependsOn(project.Id))
            {
                var candidateProject = project.Solution.GetProject(candidateProjectId);
                if (string.Equals(missingAssemblyIdentity.Name, candidateProject.AssemblyName, StringComparison.OrdinalIgnoreCase))
                {
                    // The name matches, so let's see if the full identities are equal. 
                    var compilation = await candidateProject.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
                    if (missingAssemblyIdentity.Equals(compilation.Assembly.Identity))
                    {
                        // It matches, so just add a reference to this
                        return new AddMissingReferenceCodeAction(project,
                            string.Format(FeaturesResources.Add_project_reference_to_0, candidateProject.Name),
                            new ProjectReference(candidateProjectId), missingAssemblyIdentity);
                    }
                }
            }

            // No matching project, so metadata reference
            var description = string.Format(FeaturesResources.Add_reference_to_0, missingAssemblyIdentity.GetDisplayName());
            return new AddMissingReferenceCodeAction(project, description, null, missingAssemblyIdentity);
        }
示例#13
0
        public bool Equals(IgnoreAssemblyInfo other)
        {
            if (other == null)
            {
                return(false);
            }

            if (!AssemblyIdentity.Equals(other.AssemblyIdentity, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            if (TargetsIgnored == null || TargetsIgnored.Count() == 0)
            {
                if (other.TargetsIgnored != null && other.TargetsIgnored.Count() > 0)
                {
                    return(false);
                }
            }
            else
            {
                // We could just look to see that all of the targets ignored by either object are ignored by the other, but this way
                // will prevent duplicates which is desirable since the merge method should make it easy for user to not have duplicate targets
                if (TargetsIgnored.Count() != (other.TargetsIgnored == null ? 0 : other.TargetsIgnored.Count()))
                {
                    return(false);
                }

                var sortedTargetsEnum      = TargetsIgnored.OrderBy(s => s).GetEnumerator();
                var sortedOtherTargetsEnum = other.TargetsIgnored.OrderBy(s => s).GetEnumerator();
                while (sortedTargetsEnum.MoveNext() && sortedOtherTargetsEnum.MoveNext())
                {
                    if (!sortedTargetsEnum.Current.Equals(sortedOtherTargetsEnum.Current, StringComparison.OrdinalIgnoreCase))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        public override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            var cancellationToken = context.CancellationToken;
            var root = await context.Document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            var model = await context.Document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

            var uniqueIdentities = new HashSet <AssemblyIdentity>();

            foreach (var diagnostic in context.Diagnostics)
            {
                var nodes   = FindNodes(root, diagnostic);
                var types   = GetTypesForNodes(model, nodes, cancellationToken).Distinct();
                var message = diagnostic.GetMessage();
                AssemblyIdentity identity = GetAssemblyIdentity(types, message);
                if (identity != null && !uniqueIdentities.Contains(identity) && !identity.Equals(model.Compilation.Assembly.Identity))
                {
                    uniqueIdentities.Add(identity);
                    context.RegisterCodeFix(
                        await AddMissingReferenceCodeAction.CreateAsync(context.Document.Project, identity, context.CancellationToken).ConfigureAwait(false),
                        diagnostic);
                }
            }
        }
示例#15
0
        public SymbolXmlDocumentation GetXmlDocumentation(ISymbol symbol, string preferredCultureName = null)
        {
            if (_symbolData.TryGetValue(symbol, out SymbolDocumentationData data) &&
                data.XmlDocumentation != null)
            {
                if (object.ReferenceEquals(data.XmlDocumentation, SymbolXmlDocumentation.Default))
                {
                    return(null);
                }

                return(data.XmlDocumentation);
            }

            IAssemblySymbol assembly = FindAssembly();

            if (assembly != null)
            {
                SymbolXmlDocumentation xmlDocumentation = GetXmlDocumentation(assembly, preferredCultureName)?.GetXmlDocumentation(symbol);

                if (xmlDocumentation != null)
                {
                    _symbolData[symbol] = data.WithXmlDocumentation(xmlDocumentation);
                    return(xmlDocumentation);
                }

                CultureInfo preferredCulture = null;

                if (preferredCultureName != null &&
                    !_cultures.TryGetValue(preferredCultureName, out preferredCulture))
                {
                    preferredCulture = ImmutableInterlocked.GetOrAdd(ref _cultures, preferredCultureName, f => new CultureInfo(f));
                }

                string xml = symbol.GetDocumentationCommentXml(preferredCulture: preferredCulture, expandIncludes: true);

                if (!string.IsNullOrEmpty(xml))
                {
                    xml = XmlDocumentation.Unindent(xml);

                    XElement element = XElement.Parse(xml, LoadOptions.PreserveWhitespace);

                    xmlDocumentation = new SymbolXmlDocumentation(symbol, element);

                    _symbolData[symbol] = data.WithXmlDocumentation(xmlDocumentation);
                    return(xmlDocumentation);
                }
            }

            if (!_additionalXmlDocumentationPaths.IsDefault)
            {
                if (_additionalXmlDocumentations.IsDefault)
                {
                    _additionalXmlDocumentations = _additionalXmlDocumentationPaths
                                                   .Select(f => XmlDocumentation.Load(f))
                                                   .ToImmutableArray();
                }

                string commentId = symbol.GetDocumentationCommentId();

                foreach (XmlDocumentation xmlDocumentation in _additionalXmlDocumentations)
                {
                    SymbolXmlDocumentation documentation = xmlDocumentation.GetXmlDocumentation(symbol, commentId);

                    if (documentation != null)
                    {
                        _symbolData[symbol] = data.WithXmlDocumentation(documentation);
                        return(documentation);
                    }
                }
            }

            _symbolData[symbol] = data.WithXmlDocumentation(SymbolXmlDocumentation.Default);
            return(null);

            IAssemblySymbol FindAssembly()
            {
                IAssemblySymbol containingAssembly = symbol.ContainingAssembly;

                if (containingAssembly != null)
                {
                    AssemblyIdentity identity = containingAssembly.Identity;

                    foreach (IAssemblySymbol a in Assemblies)
                    {
                        if (identity.Equals(a.Identity))
                        {
                            return(a);
                        }
                    }
                }

                return(null);
            }
        }
示例#16
0
        //  Caller should lock peFileToObjectModel
        internal CoreTypes(PEFileToObjectModel peFileToObjectModel)
        {
            INameTable             nameTable        = peFileToObjectModel.NameTable;
            PEFileReader           peFileReader     = peFileToObjectModel.PEFileReader;
            PeReader               peReader         = peFileToObjectModel.ModuleReader;
            Module                 module           = peFileToObjectModel.Module;
            AssemblyIdentity /*?*/ assemblyIdentity = module.ModuleIdentity as AssemblyIdentity;

            int systemName              = nameTable.System.UniqueKey;
            int voidName                = nameTable.Void.UniqueKey;
            int booleanName             = nameTable.Boolean.UniqueKey;
            int charName                = nameTable.Char.UniqueKey;
            int byteName                = nameTable.Byte.UniqueKey;
            int sByteName               = nameTable.SByte.UniqueKey;
            int int16Name               = nameTable.Int16.UniqueKey;
            int uint16Name              = nameTable.UInt16.UniqueKey;
            int int32Name               = nameTable.Int32.UniqueKey;
            int uint32Name              = nameTable.UInt32.UniqueKey;
            int int64Name               = nameTable.Int64.UniqueKey;
            int uint64Name              = nameTable.UInt64.UniqueKey;
            int stringName              = nameTable.String.UniqueKey;
            int intPtrName              = nameTable.IntPtr.UniqueKey;
            int uintPtrName             = nameTable.UIntPtr.UniqueKey;
            int objectName              = nameTable.Object.UniqueKey;
            int singleName              = nameTable.Single.UniqueKey;
            int doubleName              = nameTable.Double.UniqueKey;
            int decimalName             = nameTable.Decimal.UniqueKey;
            int typedReference          = nameTable.TypedReference.UniqueKey;
            int enumName                = nameTable.Enum.UniqueKey;
            int valueTypeName           = nameTable.ValueType.UniqueKey;
            int multicastDelegateName   = nameTable.MulticastDelegate.UniqueKey;
            int typeName                = nameTable.Type.UniqueKey;
            int arrayName               = nameTable.Array.UniqueKey;
            int paramArrayAttributeName = peReader.ParamArrayAttribute.UniqueKey;

            if (assemblyIdentity != null && assemblyIdentity.Equals(peReader.metadataReaderHost.CoreAssemblySymbolicIdentity))
            {
                peReader.RegisterCoreAssembly(module as Assembly);
                uint numberOfTypeDefs = peFileReader.TypeDefTable.NumberOfRows;
                for (uint i = 1; i <= numberOfTypeDefs; ++i)
                {
                    TypeDefRow typeDefRow = peFileReader.TypeDefTable[i];
                    if (!typeDefRow.IsNested)
                    {
                        int namespaceName = peFileToObjectModel.GetNameFromOffset(typeDefRow.Namespace).UniqueKey;
                        if (namespaceName == systemName)
                        {
                            int typeDefName = peFileToObjectModel.GetNameFromOffset(typeDefRow.Name).UniqueKey;
                            if (typeDefName == voidName)
                            {
                                this.SystemVoid = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.Void);
                            }
                            else if (typeDefName == booleanName)
                            {
                                this.SystemBoolean = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.Boolean);
                            }
                            else if (typeDefName == charName)
                            {
                                this.SystemChar = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.Char);
                            }
                            else if (typeDefName == byteName)
                            {
                                this.SystemByte = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.Byte);
                            }
                            else if (typeDefName == sByteName)
                            {
                                this.SystemSByte = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.SByte);
                            }
                            else if (typeDefName == int16Name)
                            {
                                this.SystemInt16 = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.Int16);
                            }
                            else if (typeDefName == uint16Name)
                            {
                                this.SystemUInt16 = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.UInt16);
                            }
                            else if (typeDefName == int32Name)
                            {
                                this.SystemInt32 = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.Int32);
                            }
                            else if (typeDefName == uint32Name)
                            {
                                this.SystemUInt32 = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.UInt32);
                            }
                            else if (typeDefName == int64Name)
                            {
                                this.SystemInt64 = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.Int64);
                            }
                            else if (typeDefName == uint64Name)
                            {
                                this.SystemUInt64 = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.UInt64);
                            }
                            else if (typeDefName == stringName)
                            {
                                this.SystemString = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.String);
                            }
                            else if (typeDefName == intPtrName)
                            {
                                this.SystemIntPtr = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.IntPtr);
                            }
                            else if (typeDefName == uintPtrName)
                            {
                                this.SystemUIntPtr = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.UIntPtr);
                            }
                            else if (typeDefName == objectName)
                            {
                                this.SystemObject = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.Object);
                            }
                            else if (typeDefName == singleName)
                            {
                                this.SystemSingle = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.Single);
                            }
                            else if (typeDefName == doubleName)
                            {
                                this.SystemDouble = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.Double);
                            }
                            else if (typeDefName == decimalName)
                            {
                                this.SystemDecimal = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                            }
                            else if (typeDefName == typedReference)
                            {
                                this.SystemTypedReference = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.TypedReference);
                            }
                            else if (typeDefName == enumName)
                            {
                                this.SystemEnum = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                            }
                            else if (typeDefName == valueTypeName)
                            {
                                this.SystemValueType = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                            }
                            else if (typeDefName == multicastDelegateName)
                            {
                                this.SystemMulticastDelegate = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                            }
                            else if (typeDefName == typeName)
                            {
                                this.SystemType = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                            }
                            else if (typeDefName == arrayName)
                            {
                                this.SystemArray = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                            }
                            else if (typeDefName == paramArrayAttributeName)
                            {
                                this.SystemParamArrayAttribute = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                            }
                        }
                    }
                }
            }
            else
            {
                uint numberOfTypeRefs = peFileReader.TypeRefTable.NumberOfRows;
                AssemblyReference /*?*/ coreAssemblyRef = peFileToObjectModel.FindAssemblyReference(peReader.metadataReaderHost.CoreAssemblySymbolicIdentity);
                if (coreAssemblyRef == null)
                {
                    //  Error...
                    coreAssemblyRef = new AssemblyReference(peFileToObjectModel, 0, peReader.metadataReaderHost.CoreAssemblySymbolicIdentity, AssemblyFlags.Retargetable);
                }
                uint coreAssemblyRefToken = coreAssemblyRef.TokenValue;
                for (uint i = 1; i <= numberOfTypeRefs; ++i)
                {
                    TypeRefRow typeRefRow = peFileReader.TypeRefTable[i];
                    if (typeRefRow.ResolutionScope != coreAssemblyRefToken)
                    {
                        continue;
                    }
                    int namespaceName = peFileToObjectModel.GetNameFromOffset(typeRefRow.Namespace).UniqueKey;
                    if (namespaceName == systemName)
                    {
                        int typeDefName = peFileToObjectModel.GetNameFromOffset(typeRefRow.Name).UniqueKey;
                        if (typeDefName == voidName)
                        {
                            this.SystemVoid = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.Void);
                        }
                        else if (typeDefName == booleanName)
                        {
                            this.SystemBoolean = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.Boolean);
                        }
                        else if (typeDefName == charName)
                        {
                            this.SystemChar = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.Char);
                        }
                        else if (typeDefName == byteName)
                        {
                            this.SystemByte = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.Byte);
                        }
                        else if (typeDefName == sByteName)
                        {
                            this.SystemSByte = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.SByte);
                        }
                        else if (typeDefName == int16Name)
                        {
                            this.SystemInt16 = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.Int16);
                        }
                        else if (typeDefName == uint16Name)
                        {
                            this.SystemUInt16 = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.UInt16);
                        }
                        else if (typeDefName == int32Name)
                        {
                            this.SystemInt32 = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.Int32);
                        }
                        else if (typeDefName == uint32Name)
                        {
                            this.SystemUInt32 = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.UInt32);
                        }
                        else if (typeDefName == int64Name)
                        {
                            this.SystemInt64 = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.Int64);
                        }
                        else if (typeDefName == uint64Name)
                        {
                            this.SystemUInt64 = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.UInt64);
                        }
                        else if (typeDefName == stringName)
                        {
                            this.SystemString = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.String);
                        }
                        else if (typeDefName == intPtrName)
                        {
                            this.SystemIntPtr = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.IntPtr);
                        }
                        else if (typeDefName == uintPtrName)
                        {
                            this.SystemUIntPtr = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.UIntPtr);
                        }
                        else if (typeDefName == objectName)
                        {
                            this.SystemObject = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.Object);
                        }
                        else if (typeDefName == singleName)
                        {
                            this.SystemSingle = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.Single);
                        }
                        else if (typeDefName == doubleName)
                        {
                            this.SystemDouble = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.Double);
                        }
                        else if (typeDefName == decimalName)
                        {
                            this.SystemDecimal = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                        }
                        else if (typeDefName == typedReference)
                        {
                            this.SystemTypedReference = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.TypedReference);
                        }
                        else if (typeDefName == enumName)
                        {
                            this.SystemEnum = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                        }
                        else if (typeDefName == valueTypeName)
                        {
                            this.SystemValueType = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                        }
                        else if (typeDefName == multicastDelegateName)
                        {
                            this.SystemMulticastDelegate = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                        }
                        else if (typeDefName == typeName)
                        {
                            this.SystemType = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                        }
                        else if (typeDefName == arrayName)
                        {
                            this.SystemArray = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                        }
                        else if (typeDefName == paramArrayAttributeName)
                        {
                            this.SystemParamArrayAttribute = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, ModuleSignatureTypeCode.NotModulePrimitive);
                        }
                    }
                }
                NamespaceReference systemNSR = peFileToObjectModel.GetNamespaceReferenceForString(coreAssemblyRef, nameTable.System);
                if (this.SystemVoid == null)
                {
                    this.SystemVoid = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Void, ModuleSignatureTypeCode.Void);
                }
                if (this.SystemBoolean == null)
                {
                    this.SystemBoolean = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Boolean, ModuleSignatureTypeCode.Boolean);
                }
                if (this.SystemChar == null)
                {
                    this.SystemChar = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Char, ModuleSignatureTypeCode.Char);
                }
                if (this.SystemByte == null)
                {
                    this.SystemByte = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Byte, ModuleSignatureTypeCode.Byte);
                }
                if (this.SystemSByte == null)
                {
                    this.SystemSByte = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.SByte, ModuleSignatureTypeCode.SByte);
                }
                if (this.SystemInt16 == null)
                {
                    this.SystemInt16 = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Int16, ModuleSignatureTypeCode.Int16);
                }
                if (this.SystemUInt16 == null)
                {
                    this.SystemUInt16 = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.UInt16, ModuleSignatureTypeCode.UInt16);
                }
                if (this.SystemInt32 == null)
                {
                    this.SystemInt32 = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Int32, ModuleSignatureTypeCode.Int32);
                }
                if (this.SystemUInt32 == null)
                {
                    this.SystemUInt32 = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.UInt32, ModuleSignatureTypeCode.UInt32);
                }
                if (this.SystemInt64 == null)
                {
                    this.SystemInt64 = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Int64, ModuleSignatureTypeCode.Int64);
                }
                if (this.SystemUInt64 == null)
                {
                    this.SystemUInt64 = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.UInt64, ModuleSignatureTypeCode.UInt64);
                }
                if (this.SystemString == null)
                {
                    this.SystemString = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.String, ModuleSignatureTypeCode.String);
                }
                if (this.SystemIntPtr == null)
                {
                    this.SystemIntPtr = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.IntPtr, ModuleSignatureTypeCode.IntPtr);
                }
                if (this.SystemUIntPtr == null)
                {
                    this.SystemUIntPtr = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.UIntPtr, ModuleSignatureTypeCode.UIntPtr);
                }
                if (this.SystemObject == null)
                {
                    this.SystemObject = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Object, ModuleSignatureTypeCode.Object);
                }
                if (this.SystemSingle == null)
                {
                    this.SystemSingle = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Single, ModuleSignatureTypeCode.Single);
                }
                if (this.SystemDouble == null)
                {
                    this.SystemDouble = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Double, ModuleSignatureTypeCode.Double);
                }
                if (this.SystemDecimal == null)
                {
                    this.SystemDecimal = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Decimal, ModuleSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemTypedReference == null)
                {
                    this.SystemTypedReference = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.TypedReference, ModuleSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemEnum == null)
                {
                    this.SystemEnum = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Enum, ModuleSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemValueType == null)
                {
                    this.SystemValueType = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.ValueType, ModuleSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemMulticastDelegate == null)
                {
                    this.SystemMulticastDelegate = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.MulticastDelegate, ModuleSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemType == null)
                {
                    this.SystemType = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Type, ModuleSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemArray == null)
                {
                    this.SystemArray = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, nameTable.Array, ModuleSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemParamArrayAttribute == null)
                {
                    this.SystemParamArrayAttribute = peFileToObjectModel.typeCache.CreateCoreTypeReference(coreAssemblyRef, systemNSR, peReader.ParamArrayAttribute, ModuleSignatureTypeCode.NotModulePrimitive);
                }
            }
        }
示例#17
0
        private Assembly TryGetAssemblyLoadedFromPath(AssemblyIdentity identity, string directory)
        {
            string pathWithoutExtension = Path.Combine(directory, identity.Name);

            foreach (var extension in RuntimeMetadataReferenceResolver.AssemblyExtensions)
            {
                AssemblyAndLocation assemblyAndLocation;
                if (_assembliesLoadedFromLocationByFullPath.TryGetValue(pathWithoutExtension + extension, out assemblyAndLocation) &&
                    identity.Equals(AssemblyIdentity.FromAssemblyDefinition(assemblyAndLocation.Assembly)))
                {
                    return assemblyAndLocation.Assembly;
                }
            }

            return null;
        }
示例#18
0
文件: CoreTypes.cs 项目: xornand/cci
        //  Caller should lock peFileToObjectModel
        internal CoreTypes(PEFileToObjectModel peFileToObjectModel)
        {
            INameTable             nameTable        = peFileToObjectModel.NameTable;
            PEFileReader           peFileReader     = peFileToObjectModel.PEFileReader;
            PeReader               peReader         = peFileToObjectModel.ModuleReader;
            Module                 module           = peFileToObjectModel.Module;
            AssemblyIdentity /*?*/ assemblyIdentity = module.ModuleIdentity as AssemblyIdentity;

            //This does more than just initialize the five types exposed above, since it is also
            //necessary to initialize any typedefs and typerefs to types with short forms
            //in such a way that they have the correct type codes.

            int systemName              = nameTable.System.UniqueKey;
            int voidName                = nameTable.Void.UniqueKey;
            int booleanName             = nameTable.Boolean.UniqueKey;
            int charName                = nameTable.Char.UniqueKey;
            int byteName                = nameTable.Byte.UniqueKey;
            int sByteName               = nameTable.SByte.UniqueKey;
            int int16Name               = nameTable.Int16.UniqueKey;
            int uint16Name              = nameTable.UInt16.UniqueKey;
            int int32Name               = nameTable.Int32.UniqueKey;
            int uint32Name              = nameTable.UInt32.UniqueKey;
            int int64Name               = nameTable.Int64.UniqueKey;
            int uint64Name              = nameTable.UInt64.UniqueKey;
            int stringName              = nameTable.String.UniqueKey;
            int intPtrName              = nameTable.IntPtr.UniqueKey;
            int uintPtrName             = nameTable.UIntPtr.UniqueKey;
            int objectName              = nameTable.Object.UniqueKey;
            int singleName              = nameTable.Single.UniqueKey;
            int doubleName              = nameTable.Double.UniqueKey;
            int decimalName             = nameTable.Decimal.UniqueKey;
            int typedReference          = nameTable.TypedReference.UniqueKey;
            int enumName                = nameTable.Enum.UniqueKey;
            int valueTypeName           = nameTable.ValueType.UniqueKey;
            int multicastDelegateName   = nameTable.MulticastDelegate.UniqueKey;
            int typeName                = nameTable.Type.UniqueKey;
            int arrayName               = nameTable.Array.UniqueKey;
            int paramArrayAttributeName = peReader.ParamArrayAttribute.UniqueKey;

            if (assemblyIdentity != null && assemblyIdentity.Equals(peReader.metadataReaderHost.CoreAssemblySymbolicIdentity))
            {
                peReader.RegisterCoreAssembly(module as Assembly);
                uint numberOfTypeDefs = peFileReader.TypeDefTable.NumberOfRows;
                for (uint i = 1; i <= numberOfTypeDefs; ++i)
                {
                    TypeDefRow typeDefRow = peFileReader.TypeDefTable[i];
                    if (!typeDefRow.IsNested)
                    {
                        int namespaceName = peFileToObjectModel.GetNameFromOffset(typeDefRow.Namespace).UniqueKey;
                        if (namespaceName == systemName)
                        {
                            int typeDefName = peFileToObjectModel.GetNameFromOffset(typeDefRow.Name).UniqueKey;
                            if (typeDefName == voidName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.Void);
                            }
                            else if (typeDefName == booleanName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.Boolean);
                            }
                            else if (typeDefName == charName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.Char);
                            }
                            else if (typeDefName == byteName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.Byte);
                            }
                            else if (typeDefName == sByteName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.SByte);
                            }
                            else if (typeDefName == int16Name)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.Int16);
                            }
                            else if (typeDefName == uint16Name)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.UInt16);
                            }
                            else if (typeDefName == int32Name)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.Int32);
                            }
                            else if (typeDefName == uint32Name)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.UInt32);
                            }
                            else if (typeDefName == int64Name)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.Int64);
                            }
                            else if (typeDefName == uint64Name)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.UInt64);
                            }
                            else if (typeDefName == stringName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.String);
                            }
                            else if (typeDefName == intPtrName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.IntPtr);
                            }
                            else if (typeDefName == uintPtrName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.UIntPtr);
                            }
                            else if (typeDefName == objectName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.Object);
                            }
                            else if (typeDefName == singleName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.Single);
                            }
                            else if (typeDefName == doubleName)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.Double);
                            }
                            else if (typeDefName == typedReference)
                            {
                                peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.TypedReference);
                            }
                            else if (typeDefName == enumName)
                            {
                                this.SystemEnum = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                            }
                            else if (typeDefName == valueTypeName)
                            {
                                this.SystemValueType = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                            }
                            else if (typeDefName == multicastDelegateName)
                            {
                                this.SystemMulticastDelegate = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                            }
                            else if (typeDefName == typeName)
                            {
                                this.SystemType = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                            }
                            else if (typeDefName == paramArrayAttributeName)
                            {
                                this.SystemParamArrayAttribute = peFileToObjectModel.GetPredefinedTypeDefinitionAtRowWorker(i, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                            }
                        }
                    }
                }
            }
            else
            {
                uint numberOfTypeRefs = peFileReader.TypeRefTable.NumberOfRows;
                AssemblyReference /*?*/ coreAssemblyRef = peFileToObjectModel.FindAssemblyReference(peFileToObjectModel.CoreAssemblySymbolicIdentity);
                if (coreAssemblyRef == null)
                {
                    //  Error...
                    coreAssemblyRef = new AssemblyReference(peFileToObjectModel, 1, peFileToObjectModel.CoreAssemblySymbolicIdentity, AssemblyFlags.Retargetable);
                }
                uint coreAssemblyRefToken = coreAssemblyRef.TokenValue;
                for (uint i = 1; i <= numberOfTypeRefs; ++i)
                {
                    TypeRefRow typeRefRow = peFileReader.TypeRefTable[i];
                    if (typeRefRow.ResolutionScope != coreAssemblyRefToken)
                    {
                        continue;
                    }
                    int namespaceName = peFileToObjectModel.GetNameFromOffset(typeRefRow.Namespace).UniqueKey;
                    if (namespaceName == systemName)
                    {
                        int typeDefName = peFileToObjectModel.GetNameFromOffset(typeRefRow.Name).UniqueKey;
                        if (typeDefName == voidName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.Void);
                        }
                        else if (typeDefName == booleanName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.Boolean);
                        }
                        else if (typeDefName == charName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.Char);
                        }
                        else if (typeDefName == byteName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.Byte);
                        }
                        else if (typeDefName == sByteName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.SByte);
                        }
                        else if (typeDefName == int16Name)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.Int16);
                        }
                        else if (typeDefName == uint16Name)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.UInt16);
                        }
                        else if (typeDefName == int32Name)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.Int32);
                        }
                        else if (typeDefName == uint32Name)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.UInt32);
                        }
                        else if (typeDefName == int64Name)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.Int64);
                        }
                        else if (typeDefName == uint64Name)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.UInt64);
                        }
                        else if (typeDefName == stringName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.String);
                        }
                        else if (typeDefName == intPtrName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.IntPtr);
                        }
                        else if (typeDefName == uintPtrName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.UIntPtr);
                        }
                        else if (typeDefName == objectName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.Object);
                        }
                        else if (typeDefName == singleName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.Single);
                        }
                        else if (typeDefName == doubleName)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.Double);
                        }
                        else if (typeDefName == typedReference)
                        {
                            peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.TypedReference);
                        }
                        else if (typeDefName == enumName)
                        {
                            this.SystemEnum = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                        }
                        else if (typeDefName == valueTypeName)
                        {
                            this.SystemValueType = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                        }
                        else if (typeDefName == multicastDelegateName)
                        {
                            this.SystemMulticastDelegate = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                        }
                        else if (typeDefName == typeName)
                        {
                            this.SystemType = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                        }
                        else if (typeDefName == paramArrayAttributeName)
                        {
                            this.SystemParamArrayAttribute = peFileToObjectModel.GetPredefinedTypeRefReferenceAtRowWorker(i, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                        }
                    }
                }
                NamespaceReference systemNSR = peFileToObjectModel.GetNamespaceReferenceForString(coreAssemblyRef, nameTable.System);
                if (this.SystemEnum == null || (peFileToObjectModel.SystemEnumAssembly != null && coreAssemblyRef != peFileToObjectModel.SystemEnumAssembly))
                {
                    this.SystemEnum = peFileToObjectModel.typeCache.CreateCoreTypeReference(peFileToObjectModel.SystemEnumAssembly ?? coreAssemblyRef, systemNSR, nameTable.Enum, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemValueType == null || (peFileToObjectModel.SystemValueTypeAssembly != null && coreAssemblyRef != peFileToObjectModel.SystemValueTypeAssembly))
                {
                    this.SystemValueType = peFileToObjectModel.typeCache.CreateCoreTypeReference(peFileToObjectModel.SystemValueTypeAssembly ?? coreAssemblyRef, systemNSR, nameTable.ValueType, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemMulticastDelegate == null || (peFileToObjectModel.SystemMulticastDelegateAssembly != null && coreAssemblyRef != peFileToObjectModel.SystemMulticastDelegateAssembly))
                {
                    this.SystemMulticastDelegate = peFileToObjectModel.typeCache.CreateCoreTypeReference(peFileToObjectModel.SystemMulticastDelegateAssembly ?? coreAssemblyRef, systemNSR, nameTable.MulticastDelegate, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemType == null || (peFileToObjectModel.SystemTypeAssembly != null && coreAssemblyRef != peFileToObjectModel.SystemTypeAssembly))
                {
                    this.SystemType = peFileToObjectModel.typeCache.CreateCoreTypeReference(peFileToObjectModel.SystemTypeAssembly ?? coreAssemblyRef, systemNSR, nameTable.Type, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                }
                if (this.SystemParamArrayAttribute == null || (peFileToObjectModel.SystemParamArrayAttributeAssembly != null && coreAssemblyRef != peFileToObjectModel.SystemParamArrayAttributeAssembly))
                {
                    this.SystemParamArrayAttribute = peFileToObjectModel.typeCache.CreateCoreTypeReference(peFileToObjectModel.SystemParamArrayAttributeAssembly ?? coreAssemblyRef, systemNSR, peReader.ParamArrayAttribute, MetadataReaderSignatureTypeCode.NotModulePrimitive);
                }
            }
        }