Exemple #1
0
        private void insertHooksIntoNewAssembly()
        {
            var sourceAssembly = sourceCodeEditor.compiledAssembly.Location;
            var hookedAssembly = DI.config.getTempFileInTempDirectory(Path.GetFileName(sourceAssembly));

            PostSharpExecution.InsertHooksAndRunPostSharpOnAssembly(sourceAssembly, hookedAssembly);
        }
Exemple #2
0
 public void InstallPostSharpHook(IGacDll iGacDll, string typeToHook, string methodToHook)
 {
     if (false == PostSharpUtils.containsO2PostSharpHooks(iGacDll.fullPath))
     {
         IISDeployment.kill_IIS_Process_W3wp();
         BackupRestoreFiles.backup(iGacDll.fullPath);
         if (PostSharpExecution.InsertHooksAndRunPostSharpOnAssembly(iGacDll.fullPath, typeToHook, methodToHook))
         {
             DI.log.debug("PostSharp hooks installed on Gac Assembly: {0} (in {1})", iGacDll.name, iGacDll.fullPath);
         }
     }
     showGacAssemblyDetails(iGacDll, false);
     //throw new NotImplementedException();
 }
        public string runPostSharpOnAssembly()
        {
            var assemblyOriginal = compileFileToExe();
            var assemblyCopy     = Files.Copy(assemblyOriginal, assemblyOriginal + "_PS.exe");

            var assembly = CecilUtils.getAssembly(assemblyCopy);

            InjectAttributes.addO2PostSharpHookAttribute(assembly);
            InjectAttributes.addOnMethodInvocationttribute(assembly, assembly.Name.Name, "*", "TestScript_MultipleCalls", "validate");

            assembly.Name.PublicKey = null;
            AssemblyFactory.SaveAssembly(assembly, assemblyCopy);
            Hacks.patchAssemblyForCecilPostSharpBug(assemblyCopy);

            InjectAttributes.addO2PostSharpHookAttribute(assemblyCopy);

            Assert.That(PostSharpExecution.runPostSharpOnAssembly(assemblyCopy));
            Assert.That(true == PostSharpUtils.arePostSharpDllsAddedAsReferences(assemblyCopy));
            Assert.That(false == PostSharpUtils.arePostSharpDllsAddedAsReferences(assemblyOriginal));
            log.info("runPostSharpOnAssembly executed ok");
            return(assemblyCopy);
        }