public void SetUp()
        {
            _verifier = PEVerifier.CreateDefault();
            Directory.CreateDirectory(TempPath);
            foreach (var file in Directory.EnumerateFiles(@AssemblyPath, "*.dll", SearchOption.TopDirectoryOnly))
            {
                Console.WriteLine(@TempPath + file.Substring(file.IndexOf("integration") + 11));
                File.Copy(file, @TempPath + file.Substring(file.IndexOf("integration") + 11), true);
            }

            var allFiles =
                Directory.EnumerateFiles(@TempPath, "*.dll", SearchOption.AllDirectories)
                .Concat(Directory.EnumerateFiles(@TempPath, "*.exe", SearchOption.AllDirectories));

            List <AssemblyDefinition> assemblies = allFiles.Select(AssemblyDefinition.ReadAssembly).ToList();

            _tracker = new AssemblyTracker(assemblies, new TypeDefinitionCache());

            var options         = new OptionSet();
            var selectorFactory = new TargetSelectorFactory();

            selectorFactory.AddOptions(options);
            options.Parse(new[] { "--regex:(.*)Locked(.*)" });

            _transformator = new AssemblyMethodsVirtualizer.AssemblyMethodsVirtualizer(
                new GeneratedMarkingAttributeStrategy("test", "nonVirtual"),
                new TargetSelectorFactory(),
                new ILCodeGenerator("<>unspeakable_"));

            _signer = new AssemblySigner(new ModuleDefinitionWriter(new FileSystem.FileSystem(), null, new List <StrongNameKeyPair>()));
        }
Exemplo n.º 2
0
        public void CreateDefault_FindsVerifier()
        {
            var verifier = PEVerifier.CreateDefault();

            var path = verifier.GetVerifierPath(PEVerifyVersion.DotNet2);

            Assert.That(path, Is.Not.Null);
            Assert.That(File.Exists(path), Is.True);
        }
 public void PeVerifySavedAssemblies()
 {
     lock (_lockObject)
     {
         foreach (var assemblyPath in _savedAssemblies)
         {
             PEVerifier.CreateDefault().VerifyPEFile(assemblyPath);
         }
     }
 }
Exemplo n.º 4
0
 private static void PeVerifyAssembly(string assemblyPath)
 {
     try
     {
         PEVerifier.CreateDefault().VerifyPEFile(assemblyPath);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         throw;
     }
 }
 public void TearDown()
 {
     if (DynamicMixinBuilder.Scope.StrongNamedModule != null)
     {
         DynamicMixinBuilder.Scope.SaveAssembly(true);
         PEVerifier.CreateDefault().VerifyPEFile(DynamicMixinBuilder.Scope.StrongNamedModule.FullyQualifiedName);
     }
     if (DynamicMixinBuilder.Scope.WeakNamedModule != null)
     {
         DynamicMixinBuilder.Scope.SaveAssembly(false);
         PEVerifier.CreateDefault().VerifyPEFile(DynamicMixinBuilder.Scope.WeakNamedModule.FullyQualifiedName);
     }
 }
Exemplo n.º 6
0
        public virtual void TearDown()
        {
            Console.WriteLine("Tearing down MethodWrapperEmitterTests");
#if !NO_PEVERIFY
            s_assemblyBuilder.Save(s_moduleBuilder.ScopeName);
            var path = s_moduleBuilder.FullyQualifiedName;

            s_assemblyBuilder = null;
            s_moduleBuilder   = null;

            PEVerifier.CreateDefault().VerifyPEFile(path);
            FileUtility.DeleteAndWaitForCompletion(path);
#endif
        }
Exemplo n.º 7
0
        public virtual void TearDown()
        {
            Console.WriteLine("Tearing down code generation tests");
#if !NO_PEVERIFY
            string[] paths = AssemblySaver.SaveAssemblies(s_scope);
            s_scope        = null;
            s_unsavedScope = null;

            foreach (string path in paths)
            {
                PEVerifier.CreateDefault().VerifyPEFile(path);
                FileUtility.DeleteAndWaitForCompletion(path);
                FileUtility.DeleteAndWaitForCompletion(path.Replace(".dll", ".pdb"));
            }
#endif
        }
Exemplo n.º 8
0
        private static void PeVerifyAssembly(string assemblyPath)
        {
#if FEATURE_ASSEMBLYBUILDER_SAVE
            try
            {
                PEVerifier.CreateDefault().VerifyPEFile(assemblyPath);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                throw;
            }
#else
            throw new PlatformNotSupportedException("AssemblyBuilder.Save() is not supported in .NET 5.0");
#endif
        }
Exemplo n.º 9
0
        public void SetUp()
        {
            AssemblyPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "IntegrationTestFiles");
            TempPath     = Path.Combine(AssemblyPath, "temp");

            if (Directory.Exists(TempPath))
            {
                Directory.Delete(TempPath, true);
            }
            Directory.CreateDirectory(TempPath);

            Thread.Sleep(500);

            var assemblyFileNames = new[] { "DummyTarget.dll" };

            foreach (var assemblyFileName in assemblyFileNames)
            {
                File.Copy(Path.Combine(AssemblyPath, assemblyFileName), GetTempPath(assemblyFileName));
            }

            _verifier = PEVerifier.CreateDefault();

            AssemblyDefinition[] assemblies = assemblyFileNames.Select(fileName => AssemblyDefinition.ReadAssembly(GetTempPath(fileName))).ToArray();
            _tracker = new AssemblyTracker(assemblies, new TypeDefinitionCache());

            _checker = MockRepository.GenerateStub <IMixinChecker> ();
            _checker.Stub(x => x.CanBeMixed(null)).Return(true).IgnoreArguments();

            _transformator = new ConstructorGenerator.ConstructorGenerator(_checker,
                                                                           new ILCodeGenerator(
                                                                               new MethodReferenceGenerator("Remotion.Interfaces, Version=1.13.73.1026, Culture=neutral, PublicKeyToken=fee00910d6e5f53b",
                                                                                                            "Remotion.Mixins.ObjectFactory",
                                                                                                            "Remotion.Reflection.ParamList"),
                                                                               _checker)
                                                                           );

            _signer = new AssemblySigner(new ModuleDefinitionWriter(new FileSystem(), null, new List <StrongNameKeyPair> ()));

            _fileSystem = new FileSystem();
        }
        private void SaveAndVerifyModuleScopeAssembly(ModuleScope moduleScope, bool strongNamed)
        {
            var path = moduleScope.SaveAssembly(strongNamed);

            PEVerifier.CreateDefault().VerifyPEFile(path);
        }
Exemplo n.º 11
0
        public void VerifyPEFile_InvalidPath()
        {
            var verifier = PEVerifier.CreateDefault();

            verifier.VerifyPEFile("Foobar whatever");
        }
Exemplo n.º 12
0
        public void VerifyPEFile_MSCorlib()
        {
            var verifier = PEVerifier.CreateDefault();

            verifier.VerifyPEFile(typeof(object).Assembly);
        }