public override IEnumerable <DependencyListEntry> GetStaticDependencies(NodeFactory factory)
        {
            PEMemoryBlock resourceDirectory = _module.PEReader.GetSectionData(_module.PEReader.PEHeaders.CorHeader.ResourcesDirectory.RelativeVirtualAddress);

            foreach (var resourceHandle in _module.MetadataReader.ManifestResources)
            {
                ManifestResource resource = _module.MetadataReader.GetManifestResource(resourceHandle);

                // Don't try to process linked resources or resources in other assemblies
                if (!resource.Implementation.IsNil)
                {
                    continue;
                }

                string resourceName = _module.MetadataReader.GetString(resource.Name);
                if (resourceName == "ILLink.Descriptors.xml")
                {
                    BlobReader reader = resourceDirectory.GetReader((int)resource.Offset, resourceDirectory.Length - (int)resource.Offset);
                    int        length = (int)reader.ReadUInt32();

                    UnmanagedMemoryStream ms;
                    unsafe
                    {
                        ms = new UnmanagedMemoryStream(reader.CurrentPointer, length);
                    }

                    var metadataManager = (UsageBasedMetadataManager)factory.MetadataManager;
                    return(DescriptorMarker.GetDependencies(factory, ms, resource, _module, "resource " + resourceName + " in " + _module.ToString(), metadataManager.FeatureSwitches));
                }
            }
            return(Array.Empty <DependencyListEntry>());
        }
예제 #2
0
 public override IEnumerable <DependencyListEntry> GetStaticDependencies(NodeFactory factory)
 {
     using (Stream fs = File.OpenRead(_fileName))
     {
         var metadataManager = (UsageBasedMetadataManager)factory.MetadataManager;
         return(DescriptorMarker.GetDependencies(factory, fs, default, default, _fileName, metadataManager.FeatureSwitches));