private void CecilifyAndExecute(Stream tbc, string outputAssembyPath) { cecilifiedCode = Cecilfy(tbc); var references = Utils.GetTrustedAssembliesPath(); var refsToCopy = new List <string> { typeof(ILParser).Assembly.Location, typeof(TypeReference).Assembly.Location, typeof(TypeHelpers).Assembly.Location }; foreach (var refPath in refsToCopy) { references.Add(refPath); } var cecilifierRunnerPath = CompilationServices.CompileExe(cecilifiedCode, references.ToArray()); Console.WriteLine("------- Cecilified Code -------"); Console.WriteLine(cecilifiedCode); Console.WriteLine("^^^^^^^ Cecilified Code ^^^^^^^"); Directory.CreateDirectory(Path.GetDirectoryName(outputAssembyPath)); CopyFilesNextToGeneratedExecutable(cecilifierRunnerPath, refsToCopy); Console.WriteLine("Cecil runner path: {0}", cecilifierRunnerPath); TestFramework.Execute("dotnet", cecilifierRunnerPath + " " + outputAssembyPath); }
internal void AssertResourceTest(string resourceName, TestKind kind, IAssemblyDiffVisitor visitor) { using (var tbc = ReadResource(resourceName, "cs", kind)) { var cecilifierTestsFolder = Path.Combine(Path.GetTempPath(), "CecilifierTests"); var cecilifiedAssemblyPath = Path.Combine(cecilifierTestsFolder, resourceName + ".dll"); var resourceCompiledAssemblyPath = CompilationServices.CompileDLL( Path.Combine(Path.GetDirectoryName(cecilifiedAssemblyPath), Path.GetFileNameWithoutExtension(cecilifiedAssemblyPath) + "_expected"), ReadToEnd(tbc), Utils.GetTrustedAssembliesPath().ToArray()); Console.WriteLine(); Console.WriteLine("Compiled from res : {0}", resourceCompiledAssemblyPath); Console.WriteLine("Generated from Cecilifier: {0}", cecilifiedAssemblyPath); AssertResourceTest(cecilifiedAssemblyPath, resourceCompiledAssemblyPath, tbc, visitor); } }