public void TestContinueWith2(AnalysisStrategy strategy)
 {
     var task = Task<string>.Factory.StartNew(() => { return "hello"; });
     var task2 = task.ContinueWith((t) => t.Result + " ben");
     task2.Wait();
     Assert.IsTrue(task2.Result.Equals("hello ben"));
 }
        public void AnalyzeSimpleSolution2(AnalysisStrategy strategy)
        {
            var callgraph = GenerateCallGraph(50);
            var syntax = GenerateCode(callgraph);
            var code = syntax.ToFullString();
            Logger.Instance.Log("CallGraphGenerator", "AnalyzeSimpleSolution2", code);
            var solution = ReachingTypeAnalysis.Utils.CreateSolution(code);
            Logger.Instance.Log("CallGraphGenerator", "AnalyzeSimpleSolution2", solution.FilePath);
            var solAnalyzer = new SolutionAnalyzer(solution);
            solAnalyzer.Analyze(strategy);
            var resolved = solAnalyzer.GenerateCallGraph();
            var resolvedNodes = resolved.GetNodes().Count();
            var callgraphNodes = callgraph.GetNodes().Count();
            Assert.IsTrue(resolvedNodes == callgraphNodes);
            var resolveEdgeCount = resolved.GetEdges().Count();
            var callgraphEdgeCount = callgraph.GetEdges().Count();

            foreach (var node in resolved.GetNodes())
            {
                //var callees = callgraph.GetCallees(node.Name);
                var callees = callgraph.GetCallees(node.MethodName);
                var resolvedCallees = resolved.GetCallees(node);
                Assert.IsTrue(callees.Count() == resolvedCallees.Count(), "Mismatched callee counts for " + node);
            }

            Assert.IsTrue(resolved.GetEdges().Count() == callgraph.GetEdges().Count());
        }
Beispiel #3
0
        public IChartResults LoadChartsData(AnalysisParametersModel parameters, IAnalysisResult analysisResult)
        {
            SetAnalysisStrategy(parameters.AnalysisMethod);
            var data    = ImportService.LoadDataByImportId(parameters.ImportIds);
            var headers = ImportService.LoadImportHeadersById(parameters.MainHeadersId);

            return(AnalysisStrategy.LoadChartsData(headers, data, analysisResult));
        }
Beispiel #4
0
        private void modifyBarButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            List <AnalysisStrategy> strategyList = this.controller.XMLDeserializeAnalysisStrategy();
            int index = this.galleryItemGroup.Items.IndexOf(this.activatedGalleryItem);
            AnalysisStrategy strategy = strategyList[index];

            InitStrategyOptionDialog(strategy, index);
            // modify both dropdown1 groups and strategy bar groups
        }
 public AnalysisStrategyOptionForm(AnalysisStrategy strategy, int strategyIndex)
 {
     this.Strategy      = strategy;
     this.strategyIndex = strategyIndex;
     InitializeComponent();
     InitConfigureTabPanel();
     InitTreeList();
     InitGeneralData(strategy);
     InitFactorGridView();
     InitController();
 }
Beispiel #6
0
        public void setDefaultStrategyList()
        {
            this.strategyList.Clear();
            AnalysisStrategy strategy     = new AnalysisStrategy();
            string           strategyName = StaticResource.defaultStrategyNameStr;
            string           description  = StaticResource.defaultStrategDescripStr;
            int testRounds = 1;

            strategy.initStrategyInfo(strategyName, description, testRounds);
            this.strategyList.Add(strategy);
        }
Beispiel #7
0
        private void InitGeneralData(AnalysisStrategy strategy)
        {
            this.strategyNameTextEdit.Text = strategy.StrategyName;
            this.strategyDescTextEdit.Text = strategy.StrategyDescription;
            this.testRoudsSpinEdit.Value   = strategy.TestRounds;
            // init the platform weight choose
            Type platformWeightSetType = strategy.PlatformWeightSetMethod.Value.GetType();

            this.platformWeightRadioGroup.SelectedIndex = StrategyOptionMapping.PlatformWeightSetTypeDict[platformWeightSetType];

            Type platformAssignType = strategy.PlatformAssignMethod.Value.GetType();

            this.platformAssignRadioGroup.SelectedIndex = StrategyOptionMapping.PlatformAssignTypeDict[platformAssignType];
        }
Beispiel #8
0
        private void createBarButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            int index = this.controller.project.StrategyList.Count;
            AnalysisStrategy strategy     = new AnalysisStrategy();
            string           strategyName = "Strategy" + index;
            string           description  = "Strategy" + index + " setting";
            int testRounds = 1;

            strategy.initStrategyInfo(strategyName, description, testRounds);
            this.controller.project.StrategyList.Add(strategy);
            this.controller.XMLSerializeAnalysisStrategyList(this.controller.project.StrategyList);

            this.galleryItemGroup.Items.Add(new GalleryItem(null, strategyName, description));
            updateDropDownGroups();
        }
Beispiel #9
0
        private void applayStrategy(int index)
        {
            if (!isTestSetGenerated)
            {
                isTestSetGenerated = true;
                this.chartTypeRibbenGroup.Enabled = true;
                this.iSave.Enabled   = true;
                this.iSaveAs.Enabled = true;
            }
            List <AnalysisStrategy> strategyList = this.controller.XMLDeserializeAnalysisStrategy();
            AnalysisStrategy        strategy     = strategyList[index];
            List <Dictionary <string, Dictionary <string, string> > > testSet = strategy.startAnalysis();

            this.testSetGridviewShow();
            this.presentDataInTestSetGrid(testSet);
            isTestSetGenerated = false;
        }
        public override void Flush(ReportAggregates reportAggregates)
        {
            if (reportAggregates.TestList == null || reportAggregates.TestList.Count == 0)
            {
                return;
            }
            this._reportAggregates = reportAggregates;

            var filter = Builders <BsonDocument> .Filter.Eq("_id", ReportId);

            var update = Builders <BsonDocument> .Update
                         .Set("endTime", DateTime.Now)
                         .Set("duration", (DateTime.Now - _startTime).Milliseconds)
                         .Set("status", StatusHierarchy.GetHighestStatus(reportAggregates.StatusList).ToString().ToLower())
                         .Set("parentLength", reportAggregates.ReportStatusStats.ParentCount)
                         .Set("passParentLength", reportAggregates.ReportStatusStats.ParentCountPass)
                         .Set("failParentLength", reportAggregates.ReportStatusStats.ParentCountFail)
                         .Set("fatalParentLength", reportAggregates.ReportStatusStats.ParentCountFatal)
                         .Set("errorParentLength", reportAggregates.ReportStatusStats.ParentCountError)
                         .Set("warningParentLength", reportAggregates.ReportStatusStats.ParentCountWarning)
                         .Set("skipParentLength", reportAggregates.ReportStatusStats.ParentCountSkip)
                         .Set("exceptionsParentLength", reportAggregates.ReportStatusStats.ParentCountExceptions)
                         .Set("childLength", reportAggregates.ReportStatusStats.ChildCount)
                         .Set("passChildLength", reportAggregates.ReportStatusStats.ChildCountPass)
                         .Set("failChildLength", reportAggregates.ReportStatusStats.ChildCountFail)
                         .Set("fatalChildLength", reportAggregates.ReportStatusStats.ChildCountFatal)
                         .Set("errorChildLength", reportAggregates.ReportStatusStats.ChildCountError)
                         .Set("warningChildLength", reportAggregates.ReportStatusStats.ChildCountWarning)
                         .Set("skipChildLength", reportAggregates.ReportStatusStats.ChildCountSkip)
                         .Set("infoChildLength", reportAggregates.ReportStatusStats.ChildCountInfo)
                         .Set("exceptionsChildLength", reportAggregates.ReportStatusStats.ChildCountExceptions)
                         .Set("grandChildLength", reportAggregates.ReportStatusStats.GrandChildCount)
                         .Set("passGrandChildLength", reportAggregates.ReportStatusStats.GrandChildCountPass)
                         .Set("failGrandChildLength", reportAggregates.ReportStatusStats.GrandChildCountFail)
                         .Set("fatalGrandChildLength", reportAggregates.ReportStatusStats.GrandChildCountFatal)
                         .Set("errorGrandChildLength", reportAggregates.ReportStatusStats.GrandChildCountError)
                         .Set("warningGrandChildLength", reportAggregates.ReportStatusStats.GrandChildCountWarning)
                         .Set("skipGrandChildLength", reportAggregates.ReportStatusStats.GrandChildCountSkip)
                         .Set("exceptionsGrandChildLength", reportAggregates.ReportStatusStats.GrandChildCountExceptions)
                         .Set("analysisStrategy", AnalysisStrategy.ToString().ToUpper());

            _reportCollection.UpdateOne(filter, update);
            InsertUpdateSystemAttribute();
        }
Beispiel #11
0
        public IAnalysisResult AnalyzeData(AnalysisParametersModel parameters)
        {
            SetAnalysisStrategy(parameters.AnalysisMethod);
            var data    = ImportService.LoadDataByImportId(parameters.ImportIds);
            var headers = ImportService.LoadImportHeadersById(parameters.MainHeadersId);

            var analysisHistory = new AnalysisHistory {
                AnalysisDate = DateTime.Now
            };
            var analysisData = data.GroupBy(d => d.Header.Import).Select(g => new AnalysisData
            {
                AnalysisHistory = analysisHistory,
                Import          = g.Key
            }).ToList();

            AnalysisRepository.SaveAnalysis(analysisHistory, analysisData);

            return(AnalysisStrategy.AnalyzeData(headers, data, parameters.Args));
        }
        public List <AnalysisStrategy> XMLDeserializeAnalysisStrategy()
        {
            List <AnalysisStrategy> strategyList = new List <AnalysisStrategy>();
            List <string>           fileList     = this.getXMLFileList(workFolder + strategyFileFoder);

            if (fileList.Count > 0)
            {
                foreach (string file in fileList)
                {
                    try
                    {
                        Stream           stream   = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
                        AnalysisStrategy strategy = analysisStrategySerializer.Deserialize(stream) as AnalysisStrategy;
                        // we need to reload the variable relation in strategy
                        if (this.project != null)
                        {
                            strategy.updateData(this.project);
                        }

                        strategyList.Add(strategy);
                        stream.Close();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.StackTrace);
                    }
                }
            }
            else
            {  // configure file do not exsit ,just create and use the default strategy
                this.project.setDefaultStrategyList();
                this.XMLSerializeAnalysisStrategyList(this.project.StrategyList);
                strategyList = this.project.StrategyList;
            }

            return(strategyList);
        }
 public SessionStatusStats(AnalysisStrategy strategy)
 {
     _strategy = strategy;
 }
		/// <summary>
		/// IMPORTANT: OnDemandSolvers need an OnDemand Dispatcher
		/// We cannot use the SyncronousDistacther because it doesn't look for the 
		/// methods when they are not available. This only works with the entire solution
		/// analysis!!!!
		/// </summary>
		/// <param name="dispatcher"></param>
		public void Analyze(AnalysisStrategy strategy = AnalysisStrategy.NONE)
		{
			if (strategy == AnalysisStrategy.NONE)
			{
				strategy = ConvertToEnum(ConfigurationManager.AppSettings["Strategy"]);
			}
           

			// TOOD: hack -- set the global solution
			ProjectCodeProvider.Solution = this.Solution;

			switch (strategy)
            {
                case AnalysisStrategy.ONDEMAND_SYNC:
                    {
                        this.Dispatcher = new OnDemandSyncDispatcher();
                        AnalyzeOnDemand();

                        break;
                    }
				case AnalysisStrategy.ENTIRE_SYNC:
					{
						this.Dispatcher = new SynchronousLocalDispatcher();
						AnalyzeEntireSolution();

						break;
					}
				case AnalysisStrategy.ONDEMAND_ASYNC:
                    {
                        //this.Dispatcher = new QueueingDispatcher(this.Solution);
                        this.Dispatcher = new AsyncDispatcher();
                        AnalyzeOnDemandAsync(AnalysisStrategy.ONDEMAND_ASYNC).Wait();
                        break;
                    }
                case AnalysisStrategy.ONDEMAND_ORLEANS:
                    {
                        //var applicationPath = AppDomain.CurrentDomain.BaseDirectory;
                        var orleansPath = System.Environment.GetEnvironmentVariable("ORLEANSSDK");
                            //@"C:\Microsoft Project Orleans SDK v1.0\SDK\LocalSilo\Applications\ReachingTypeAnalysis";
                        var applicationPath = Path.Combine(Path.Combine(orleansPath, @"LocalSilo\Applications"), "ReachingTypeAnalysis");

                        var appDomainSetup = new AppDomainSetup
                        {
                            AppDomainInitializer = InitSilo,
                            //ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
                            ApplicationBase = applicationPath,
                            ApplicationName = "ReachingTypeAnalysis",
                            AppDomainInitializerArguments = new string[] { },
                            ConfigurationFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ReachingTypeAnalysis.exe.config")
                        };
                        // set up the Orleans silo
                        var hostDomain = AppDomain.CreateDomain("OrleansHost", null,appDomainSetup);

                        var xmlConfig = "DevTestClientConfiguration.xml";
                        Contract.Assert(File.Exists(xmlConfig), "Can't find " + xmlConfig);
                        try
                        {                            
                            GrainClient.Initialize(xmlConfig);
                            Logger.Instance.Log("SolutionAnalyzer", "Analyze", "Orleans silo initialized");
                        }
                        catch (Exception e)
                        {
                            Logger.Instance.Log("SolutionAnalyzer", "Analyze", e.Message);
                            throw e;
                            //break;
                        }
						// Create a Grain for the solution
                        ISolutionGrain solutionGrain = SolutionGrainFactory.GetGrain("Solution");
                        if (SourceCode != null)
                        {
                           solutionGrain.SetSolutionSource(SourceCode).Wait();
                           IProjectCodeProviderGrain projectGrain = ProjectCodeProviderGrainFactory.GetGrain("MyProject");
                           projectGrain.SetProjectSourceCode(SourceCode);
                        }
                        else {
                            Contract.Assert(Solution.FilePath!=null);
                            solutionGrain.SetSolutionPath(this.Solution.FilePath).Wait();
                            foreach(var project in this.Solution.Projects)
                            {
                                IProjectCodeProviderGrain projectGrain = ProjectCodeProviderGrainFactory.GetGrain(project.Name);
                                projectGrain.SetProjectPath(project.FilePath).Wait();
                            }                            
                        }
                        // make a dispatcher
                        this.Dispatcher = new OrleansDispatcher();
                        // run
                        AnalyzeOnDemandAsync(AnalysisStrategy.ONDEMAND_ORLEANS).Wait();

                        break;
                    }
                case AnalysisStrategy.ENTIRE_ASYNC:
					{
                        //this.Dispatcher = new QueueingDispatcher(this.Solution);
                        this.Dispatcher = new AsyncDispatcher();
                        AnalyzeEntireSolutionAsync();

						break;
					}
				default:
                    {
                        throw new ArgumentException("Unknown value for Solver " + ConfigurationManager.AppSettings["Solver"]);
                    }
            }
        }
        private static void AnalyzeExample(string source, RunChecks checker, AnalysisStrategy strategy = AnalysisStrategy.NONE)
        {
            //var solution = ReachingTypeAnalysis.Utils.CreateSolution(source);
            //var solAnalyzer = new SolutionAnalyzer(solution);
            var solAnalyzer = new SolutionAnalyzer(source);
            solAnalyzer.Analyze(strategy);
            var callgraph = solAnalyzer.GenerateCallGraph();

            checker(solAnalyzer, callgraph);
        }
 private static void AnalizeSolution(Solution solution, RunChecks checker, AnalysisStrategy type = AnalysisStrategy.NONE)
 {
     var solAnalyzer = new SolutionAnalyzer(solution);
     solAnalyzer.Analyze(type);
     var callgraph = solAnalyzer.GenerateCallGraph();
     checker(solAnalyzer, callgraph);
 }
Beispiel #17
0
        void InitStrategyOptionDialog(AnalysisStrategy strategy, int index)
        {
            strategyOptionForm = new AnalysisStrategyOptionForm(strategy, index);

            strategyOptionForm.ShowDialog(this);
        }
 protected void SetAnalysisStrategy(AnalysisStrategy strategy)
 {
     _strategy           = strategy;
     _sessionStatusStats = new SessionStatusStats(strategy);
 }
		/// <summary>
		/// Try to get the roslyn methods on the fly
		/// Currently works with one project.
		/// </summary>
		public async Task AnalyzeOnDemandAsync(AnalysisStrategy strategy)
		{
			Contract.Assert(this.Dispatcher != null);
			var cancellationSource = new CancellationTokenSource();
			var triple = await ProjectCodeProvider.GetProviderContainingEntryPointAsync(this.Solution, cancellationSource.Token);
			if (triple != null)
			{
				// cancel out outstanding processing tasks
				//cancellationSource.Cancel();	

				var provider = triple.Item1;
				var mainSymbol = triple.Item2;
                var tree = triple.Item3;
                var model = provider.Compilation.GetSemanticModel(tree);
				var methodVisitor = new MethodSyntaxProcessor(model, tree, mainSymbol);

				//var mainMethodEntity = methodVisitor.ParseMethod();
                var mainMethodDescriptor = Utils.CreateMethodDescriptor(mainSymbol);
                var mainMethodEntityDescriptor = EntityFactory.Create(mainMethodDescriptor, this.Dispatcher);

                IEntityProcessor mainMethodEntityProcessor = null;
                switch(strategy)
                {
                    case AnalysisStrategy.ONDEMAND_ORLEANS:
                        var methodEntityGrain = await OrleansDispatcher.CreateMethodEntityGrain((OrleansEntityDescriptor)mainMethodEntityDescriptor);
                        // Option 1: Direcly using the Grain
                        await methodEntityGrain.DoAnalysisAsync();
                        // Option 2: Using the processor (requires making the processor serializable)
                        //mainMethodEntityProcessor = await methodEntityGrain.GetEntityWithProcessorAsync();
                        //await mainMethodEntityProcessor.DoAnalysisAsync();
                        break;
                    case AnalysisStrategy.ONDEMAND_ASYNC:
                        mainMethodEntityProcessor = await this.Dispatcher.GetEntityWithProcessorAsync(mainMethodEntityDescriptor);
					    var mainMethodEntity = ((MethodEntityProcessor)mainMethodEntityProcessor).MethodEntity;
                        this.Dispatcher.RegisterEntity(mainMethodEntity.EntityDescriptor, mainMethodEntity);
                        await mainMethodEntityProcessor.DoAnalysisAsync();
                        break;
                }
                //await Task.WhenAll(mainMethodEntityProcessor.DoAnalysisAsync());
                //Thread.Sleep(1000);
				Logger.Instance.Log("SolutionAnalyzer", "AnalyzeOnDemandAsync", "--- Done with propagation ---");
			}
		}
Beispiel #20
0
 public void AnalyzeLast <TPatientKey>(Patient <TPatientKey> patient) where TPatientKey : IEquatable <TPatientKey>
 {
     AnalysisResult = AnalysisStrategy.AnalyzeLast(patient);
 }
 public void TestTaskStart(AnalysisStrategy strategy)
 {
     var task = Task<string>.Factory.StartNew(() => { return "hello"; });
     Assert.IsTrue(task.Result.Equals("hello"));
 }
Beispiel #22
0
 public void Analyze <TPatientKey>(HealthMeasurement <Guid, Guid> healthState, Patient <TPatientKey> patient) where TPatientKey : IEquatable <TPatientKey>
 {
     AnalysisResult = AnalysisStrategy.Analyze <Guid>(healthState, patient as Patient <Guid>);
 }