Ejemplo n.º 1
0
        public void AnalyzeAndWeaveExternals()
        {
            NameValueCollection config = new NameValueCollection();

            config.Add("OutputImagePath", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Woven"));
            config.Add("ShouldSignAssembly", "false");
            config.Add("OutputImageSNK", "");
            config.Add("RepositoryFilename", CreateFullPath("starlight.yap"));
            config.Add("InstallFolder", installationFolder);

            Directory.CreateDirectory(config["OutputImagePath"]);

            CecilILAnalyzer analyzer = new CecilILAnalyzer();

            analyzer.Initialize(FilenameSource, config);

            // Run the analyzer
            IList <TypeElement> ret = analyzer.ExtractTypeElements();

            analyzer.ProcessUnresolvedTypes();
            analyzer.Close();

            // Change the types
            Composestar.Repository.RepositoryAccess repository = new Composestar.Repository.RepositoryAccess(CreateFullPath("starlight.yap"));

            TypeElement te = null;
            External    e;

            #region Add external '??' (String) to ??
            //te = repository.GetTypeElement("ConsoleTestTarget.HelloWorld");
            //i = new Internal();
            //i.ParentTypeId = te.Id;
            //i.Name = "HelloWorldStringInternal";
            //i.NameSpace = "ConsoleTestTarget.HelloWorld";
            //i.Type = "System.String, mscorlib";
            //Composestar.Repository.DataStoreContainer.Instance.StoreObject(i);
            #endregion


            // Run the weaver
            CecilILWeaver weaver = new CecilILWeaver();
            weaver.Initialize(FilenameSource, config);
            weaver.DoWeave(); // Place debugger here or perform Asserts
            weaver.Close();
        }
Ejemplo n.º 2
0
        public void AnalyzeAndWeaveTestFilters()
        {
            NameValueCollection config = new NameValueCollection();

            config.Add("OutputImagePath", AppDomain.CurrentDomain.BaseDirectory);
            config.Add("ShouldSignAssembly", "false");
            config.Add("OutputImageSNK", "");
            config.Add("RepositoryFilename", CreateFullPath("starlight.yap"));
            config.Add("InstallFolder", installationFolder);

            CecilILAnalyzer analyzer = new CecilILAnalyzer();

            analyzer.Initialize(FilenameSource, config);

            // Run the analyzer
            IList <TypeElement> ret = analyzer.ExtractTypeElements();

            analyzer.Close();

            // Change the types
            Composestar.Repository.RepositoryAccess repository = new Composestar.Repository.RepositoryAccess(CreateFullPath("starlight.yap"));

            TypeElement te = null;

            te = repository.GetTypeElement("ConsoleTestTarget.HelloWorld");
            MethodElement me = null;

            me = repository.GetMethodElementBySignature(te, "System.String GetMessage()");

            // Add some inputfilters

            Block block  = new Block();
            Block block2 = new Block();

            block2.Label.Id = 4;
            FilterAction beforeAction = new FilterAction("BeforeAction", "", "");

            Composestar.Repository.LanguageModel.ConditionExpressions.ConditionExpression ce = new Composestar.Repository.LanguageModel.ConditionExpressions.True();
            Branch branch = new Composestar.Repository.LanguageModel.Inlining.Branch(ce);

            branch.TrueBlock  = block;
            branch.FalseBlock = block2;
            FilterAction errorAction = new FilterAction("ErrorAction", "", "");
            Jump         jump        = new Jump(new Label(2));

            block.Label.Id        = 2;
            beforeAction.Label.Id = 3;
            block2.addInstruction(beforeAction);
            block2.addInstruction(errorAction);

            ContextInstruction ci  = new ContextInstruction(ContextInstruction.CHECK_INNER_CALL, 1000, block2);
            ContextInstruction ci2 = new ContextInstruction(ContextInstruction.RESET_INNER_CALL, 1000, null);
            ContextInstruction ci3 = new ContextInstruction(ContextInstruction.SET_INNER_CALL, 1000, null);

            block.addInstruction(ci);
            block.addInstruction(ci2);
            block.addInstruction(ci3);

            // block2.addInstruction(branch);
            // block2.addInstruction(jump);

            me.MethodBody.InputFilter = block;
            Composestar.Repository.DataStoreContainer.Instance.StoreObject(me);

            repository.CloseDatabase();

            // Run the weaver
            // OC: CecilWeaver should not be created directly!
            //CecilILWeaver weaver = new CecilILWeaver();
            //weaver.Initialize(FilenameSource, config);
            //weaver.DoWeave(); // Place debugger here or perform Asserts
            //weaver.Close();
        }
Ejemplo n.º 3
0
        public void CanCreateAnalyzerThroughDIHelper()
        {
            CecilILAnalyzer analyzer = DIHelper.CreateObject <CecilILAnalyzer>(svcContainer);

            Assert.IsNotNull(analyzer);
        }