示例#1
0
        public ContainerRegistrationAnalysisStageProcess(IDaemonProcess process, IContextBoundSettingsStore settingsStore, ITypeUsageManager typeUsageManager, SolutionAnalyzer solutionAnalyzer)
        {
            this.process          = process;
            this.settingsStore    = settingsStore;
            this.typeUsageManager = typeUsageManager;

            cachedComponentRegistrations = solutionAnalyzer.Analyze().ToList();
        }
示例#2
0
        protected void RunTest(string testName, Action <IEnumerable <RegistrationInfo> > action)
        {
            string fileName = testName + Extension;
            var    dataPath = new DirectoryInfo(Path.Combine(SolutionItemsBasePath, RelativeTypesPath));
            var    fileSet  = dataPath.GetFiles("*.cs").SelectNotNull(fileInfo => Path.Combine(RelativeTypesPath, fileInfo.Name)).Concat(new[] { fileName });

            WithSingleProject(fileSet, (lifetime, project) => RunGuarded(() =>
            {
                var searchDomainFactory = ShellInstance.GetComponent <SearchDomainFactory>();
                var patternSearcher     = new PatternSearcher(searchDomainFactory);
                var solutionnAnalyzer   = new SolutionAnalyzer(patternSearcher);
                solutionnAnalyzer.AddContainer(ContainerInfo);

                var componentRegistrations = solutionnAnalyzer.Analyze();

                action(componentRegistrations);
            }));
        }
示例#3
0
        public void AnalyzeComplexTest()
        {
            var solutionAnalyzer = new SolutionAnalyzer();
            var solutionData     = solutionAnalyzer.Analyze(@"..\..\CodeAnalyzer\TestData\ApplicationForAnalysis\ApplicationForAnalysis.sln");

            Assert.AreEqual("ApplicationForAnalysis.sln", solutionData.SolutionFileName);
            Assert.AreEqual("ApplicationForAnalysis", solutionData.SolutionName);
            Assert.AreEqual(@"..\..\CodeAnalyzer\TestData\ApplicationForAnalysis", solutionData.SolutionFolderName);

            Assert.AreEqual(3, solutionData.Projects.Count);
            Assert.AreEqual("WinFormProject", solutionData.Projects[0].ProjectName);
            Assert.AreEqual(@"WinFormProject\WinFormProject.csproj", solutionData.Projects[0].ProjectFileName);
            Assert.AreEqual("WinFormProject", solutionData.Projects[0].ProjectFolder);

            Assert.AreEqual("ClassLibraryProject", solutionData.Projects[1].ProjectName);
            Assert.AreEqual(@"ClassLibraryProject\ClassLibraryProject.csproj", solutionData.Projects[1].ProjectFileName);
            Assert.AreEqual("ClassLibraryProject", solutionData.Projects[1].ProjectFolder);

            Assert.AreEqual("WebProject", solutionData.Projects[2].ProjectName);
            Assert.AreEqual(@"WebProject\WebProject.csproj", solutionData.Projects[2].ProjectFileName);
            Assert.AreEqual("WebProject", solutionData.Projects[2].ProjectFolder);
        }
        //private const string SolutionPath = @"D:\Work\Upwork\1_QueryTree\QueryTree.sln";


        private static async Task Main(string[] args)
        {
            // Attempt to set the version of MSBuild.
            var visualStudioInstances = MSBuildLocator.QueryVisualStudioInstances().ToArray();
            var instance = visualStudioInstances.Length == 1
                           // If there is only one instance of MSBuild on this machine, set that as the one to use.
                                ? visualStudioInstances[0]
                           // Handle selecting the version of MSBuild you want to use.
                                : SelectVisualStudioInstance(visualStudioInstances);

            Console.WriteLine($"Using MSBuild at '{instance.MSBuildPath}' to load projects.");

            // NOTE: Be sure to register an instance with the MSBuildLocator
            //       before calling MSBuildWorkspace.Create()
            //       otherwise, MSBuildWorkspace won't MEF compose.
            MSBuildLocator.RegisterInstance(instance);

            using (var workspace = MSBuildWorkspace.Create()) {
                // Print message for WorkspaceFailed event to help diagnosing project load failures.
                workspace.WorkspaceFailed += (o, e) => Console.WriteLine(e.Diagnostic.Message);

                Console.WriteLine($"Loading solution '{SolutionPath}'");

                // Attach progress reporter so we print projects as they are loaded.
                var solution = await workspace.OpenSolutionAsync(SolutionPath, new ConsoleProgressReporter());

                Console.WriteLine($"Finished loading solution '{SolutionPath}'");

                //TODO:
                var engine = new SolutionAnalyzer();
                var result = engine.Analyze(solution).Result;
            }

            Console.WriteLine("done");
            Console.ReadLine();
        }
示例#5
0
 public RegisteredComponentsContextSearch(SolutionAnalyzer solutionAnalyzer, IShellLocks locks)
 {
     this.locks          = locks;
     cachedRegistrations = solutionAnalyzer.Analyze();
 }