public void ImportModuleReference()
        {
            var assembly = NetAssemblyFactory.CreateAssembly(DummyAssemblyName, true);
            var image    = assembly.NetDirectory.MetadataHeader.LockMetadata();
            var importer = new ReferenceImporter(image);

            var module    = new ModuleReference("SomeModule");
            var newModule = importer.ImportModule(module);

            Assert.NotSame(module, newModule);
            Assert.Equal(image, newModule.Image);
            Assert.Equal(newModule.Name, newModule.Name);
        }
        public void PersistentPInvokeMap()
        {
            var assembly = NetAssemblyFactory.CreateAssembly(DummyAssemblyName, true);
            var header   = assembly.NetDirectory.MetadataHeader;

            var image    = header.LockMetadata();
            var importer = new ReferenceImporter(image);
            var method   = CreateAndAddDummyMethod(image);
            var newMap   = new ImplementationMap(importer.ImportModule(new ModuleReference("SomeModule")),
                                                 "SomeImport",
                                                 ImplementationMapAttributes.CharSetUnicode);

            method.PInvokeMap  = newMap;
            method.Attributes |= MethodAttributes.PInvokeImpl;

            var mapping = header.UnlockMetadata();

            image  = header.LockMetadata();
            method = (MethodDefinition)image.ResolveMember(mapping[method]);
            Assert.NotNull(method.PInvokeMap);
            Assert.Equal(newMap.ImportScope, method.PInvokeMap.ImportScope, _comparer);
            Assert.Equal(newMap.ImportName, method.PInvokeMap.ImportName);
            Assert.Equal(newMap.Attributes, method.PInvokeMap.Attributes);
        }