Пример #1
0
        public CrossDomainHelper(string[] absoluteFilenames, string assemblyName, string compilerOptions)
        {
            var compileResult = CompilerUtil.Compile(absoluteFilenames, assemblyName, compilerOptions: compilerOptions);

            _assemblyUtility = new AssemblyUtility(compileResult.Assembly);
            _metacomments    = compileResult.Metacomments;
        }
Пример #2
0
        public void EnumeratesAssemblyDependencies()
        {
            var cr = CompilerUtil.Compile(new[] {
                Path.Combine(
                    ComparisonTest.TestSourceFolder,
                    @"SpecialTestCases",
                    "EnumeratesAssemblyDependencies.cs"
                    )
            }, Path.Combine("DependencyTests", "EnumeratesAssemblyDependencies"));
            var assembly = cr.Assembly;

            var translator = new AssemblyTranslator(
                new Translator.Configuration {
                IncludeDependencies = false
            }
                );

            var assemblyDefinition = translator.LoadAssembly(assembly.Location);

            translator = new AssemblyTranslator(
                new Translator.Configuration {
                IncludeDependencies = true
            }
                );

            var assemblyPlusDependencies = translator.LoadAssembly(assembly.Location);

            Assert.AreNotEqual(
                (from ad in assemblyDefinition select ad.FullName).ToArray(),
                (from ad in assemblyPlusDependencies select ad.FullName).ToArray()
                );
        }
Пример #3
0
        public CrossDomainHelper(string[] absoluteFilenames, string assemblyName, string compilerOptions, string currentMetaRevision)
        {
            var compileResult = CompilerUtil.Compile(absoluteFilenames, assemblyName, compilerOptions, currentMetaRevision);

            _assemblyUtility = new AssemblyUtility(compileResult.Assembly);
            _metacomments    = compileResult.Metacomments;
            _wasCached       = compileResult.WasCached;
        }
Пример #4
0
        public ComparisonTest(
            EvaluatorPool pool,
            IEnumerable <string> filenames, string outputPath,
            string[] stubbedAssemblies  = null, TypeInfoProvider typeInfo = null,
            AssemblyCache assemblyCache = null, string compilerOptions    = ""
            )
        {
            var started = DateTime.UtcNow.Ticks;

            OutputPath    = outputPath;
            EvaluatorPool = pool;

            var extensions        = (from f in filenames select Path.GetExtension(f).ToLower()).Distinct().ToArray();
            var absoluteFilenames = (from f in filenames select Path.Combine(TestSourceFolder, Portability.NormalizeDirectorySeparators(f)));

            if (extensions.Length != 1)
            {
                throw new InvalidOperationException("Mixture of different source languages provided.");
            }

            var assemblyNamePrefix = Path.GetDirectoryName(outputPath).Split(new char[] { '\\', '/' }).Last();
            var assemblyName       = Path.Combine(
                assemblyNamePrefix,
                Path.GetFileName(outputPath).Replace(".js", "")
                );

            switch (extensions[0])
            {
            case ".exe":
            case ".dll":
                var fns = absoluteFilenames.ToArray();
                if (fns.Length > 1)
                {
                    throw new InvalidOperationException("Multiple binary assemblies provided.");
                }

                Assembly = Assembly.LoadFile(fns[0]);
                break;

            default:
                CompileResult = CompilerUtil.Compile(absoluteFilenames, assemblyName, compilerOptions: compilerOptions);
                Assembly      = CompileResult.Assembly;
                break;
            }

            if (typeInfo != null)
            {
                typeInfo.ClearCaches();
            }

            StubbedAssemblies = stubbedAssemblies;
            TypeInfo          = typeInfo;
            AssemblyCache     = assemblyCache;

            var ended = DateTime.UtcNow.Ticks;

            CompilationElapsed = TimeSpan.FromTicks(ended - started);
        }