コード例 #1
0
        public void GetObjects_Should_ReturnAnObjectForEachClass_When_ClassesAreMarkedUp()
        {
            // whoa, inception, test using the test assembly that has a class in it marked up.
            string testAssemblyName = Assembly.GetExecutingAssembly().ManifestModule.Name;

            var target = new AssemblyInterrogator(testAssemblyName);
            string errors;
            bool success = target.PopulateItemsToBench(out errors);
            List<Object> list = target.ItemsToBench;

            Assert.AreEqual(true, success);
            Assert.AreEqual(2, list.Count);
            Assert.IsTrue((from item in list where item is TestBenchmarkClass1 select item).Count() == 1);
            Assert.IsTrue((from item in list where item is TestBenchmarkClass2 select item).Count() == 1);
        }
コード例 #2
0
ファイル: CompileProcess.cs プロジェクト: schifflee/Terminals
        private AssemblyInfo ReflectAssemblyInfo(string archivePath, string uri, CompileProcess compileProcess)
        {
            AssemblyInfo info = new AssemblyInfo();

            AppDomain domain = null;

            try
            {
                string appDomainName = "Interrogator";

                AppDomainSetup domainSetup = new AppDomainSetup();
                domainSetup.ApplicationName = appDomainName;
                domainSetup.ApplicationBase = new FileInfo(Application.ExecutablePath).DirectoryName;

                domain = AppDomain.CreateDomain(appDomainName, null, domainSetup);

                AssemblyInterrogator remoteWorker = (AssemblyInterrogator)domain.CreateInstanceAndUnwrap(typeof(AssemblyInterrogator).Assembly.FullName, typeof(AssemblyInterrogator).FullName);

                string errorMessage, exceptionMessage;

                if (!remoteWorker.GetAssemblyInfo(archivePath, uri, out info, out errorMessage, out exceptionMessage))
                {
                    if (RC.ShouldWrite(ConsoleVerbosity.Debug) && String.IsNullOrEmpty(exceptionMessage) == false)
                    {
                        throw new Exception(errorMessage + Environment.NewLine + exceptionMessage);
                    }
                    else
                    {
                        throw new Exception(errorMessage);
                    }
                    //throw new Exception(string.Format("{0} : {1}", Rpx.Strings.Compiler_UnableToLoadAsm, uri));
                }

                info = AssemblyInfo.Clone(info);

                compileProcess.PassArguments = info.PassArgs;
            }
            finally
            {
                if (domain != null)
                {
                    AppDomain.Unload(domain);
                }
            }

            return(info);
        }