Ejemplo n.º 1
0
        public void TestMethod1()
        {
            Stopwatch watch = new Stopwatch();

            try
            {
                string path = "Assemblies/mscorlib.dll";
                if (!File.Exists(path))
                {
                    Assert.Fail("File not found");
                    return;
                }
                var assembly = CilAssembly.Create(path);
                watch.Start();
                using (StreamWriter file = new StreamWriter("../../Output/foo.il"))
                {
                    assembly.WriteTo(file);
                    watch.Stop();
                    file.WriteLine("//Time elapsed: " + watch.Elapsed);
                    assembly.Dispose();
                }
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
                return;
            }
            Assert.IsTrue(true);
        }
Ejemplo n.º 2
0
        public async void TryOpenAssembly(string path)
        {
            try
            {
                CilAssembly newAssm = await Task.Run(() => CilAssembly.Create(path));

                AddAssembly(newAssm);
            }
            catch
            {
                Console.WriteLine("Failed to open " + path);
            }
        }
Ejemplo n.º 3
0
        public void TestMethod1()
        {
            var watch = new Stopwatch();

            var path = "demo1.exe";

            if (!File.Exists(path))
            {
                var thisAssembly = typeof(CilTests).GetTypeInfo().Assembly;
                var resourceName =
                    thisAssembly.GetManifestResourceNames().First(r => r.EndsWith("Demo1.exe"));

                var fileName = GetFileNameFromResourceName(resourceName);

                using (var fileStream = File.Create(fileName))
                {
                    using (var resource = thisAssembly.GetManifestResourceStream(resourceName))
                    {
                        resource.CopyTo(fileStream);
                    }
                }
            }

            const string outputDirectory = "Output";

            if (!File.Exists(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }

            var assembly = CilAssembly.Create(path);

            watch.Start();
            using (var file = new StreamWriter(new FileStream($"{outputDirectory}/foo.il", FileMode.Create)))
            {
                assembly.WriteTo(file);
                watch.Stop();
                file.WriteLine("//Time elapsed: " + watch.Elapsed);
                assembly.Dispose();
            }

            Assert.True(true);
        }