Ejemplo n.º 1
0
        public override bool Execute()
        {
            try
            {
                ILWeaver           weaver         = new ILWeaver();
                AssemblyDefinition weavedAssembly = null;

                string[] assemblyDirectories = (this.AssemblyDirectories ?? string.Empty).Split(new char[] { ',' });

                using (FileStream input = File.Open(this.AssemblyPath, FileMode.Open))
                {
                    weavedAssembly = weaver.Weave(input, assemblyDirectories, this.OptimizedCode);
                }

                using (FileStream output = File.Open(this.AssemblyPath, FileMode.Create))
                {
                    weavedAssembly.Write(output);
                }
            }
            catch (Exception ex)
            {
                this.Log.LogError(ex.Message + "\n\n" + ex.StackTrace);
            }

            return(!this.Log.HasLoggedErrors);
        }
Ejemplo n.º 2
0
        public override bool Execute()
        {
            try
            {
                ILWeaver weaver = new ILWeaver();
                AssemblyDefinition weavedAssembly = null;

                string[] assemblyDirectories = (this.AssemblyDirectories ?? string.Empty).Split(new char[] { ',' });

                using (FileStream input = File.Open(this.AssemblyPath, FileMode.Open))
                {
                    weavedAssembly = weaver.Weave(input, assemblyDirectories, this.OptimizedCode);
                }

                using (FileStream output = File.Open(this.AssemblyPath, FileMode.Create))
                {
                    weavedAssembly.Write(output);
                }
            }
            catch (Exception ex)
            {
                this.Log.LogError(ex.Message + "\n\n" + ex.StackTrace);
            }

            return !this.Log.HasLoggedErrors;
        }
Ejemplo n.º 3
0
        public void TestWeave()
        {
            using (FileStream input = new FileStream(_executable, FileMode.Open, FileAccess.Read))
            using (FileStream output = new FileStream(_executableWeaved, FileMode.Create, FileAccess.Write))
            {
                var weaver = new ILWeaver();
                var assemblyDefinition = weaver.Weave(input, new string[0], false);
                assemblyDefinition.Write(output);
            }

            string weavedOutput = this.GetWeavedOutput();

            Assert.That(weavedOutput, Is.Not.StringContaining("Original Void2"), "Execution of AnnotatedClass.Void2 should have been skipped");
        }