public void SetUp()
        {
            var analyzerResult = TestProjectsSetupFixture.EfAnalyzerResults.First(a =>
                                                                                  a.ProjectResult.ProjectFilePath == TestProjectsSetupFixture.Ef6ProjectPath);

            var featureDetector = new FeatureDetector(ConfigFile);

            _featureDetectionResult = featureDetector.DetectFeaturesInProject(analyzerResult);
        }
Example #2
0
        public void DetectFeaturesInProject_Detects_Features_In_Specified_Project()
        {
            const string mvcFeature               = "AspNetMvcFeature";
            const string webApiFeature            = "AspNetWebApiFeature";
            const string sqlServerProviderFeature = "SqlServerProviderFeature";
            const string postgresProviderFeature  = "PostgresProviderFeature";

            var results = FeatureDetector.DetectFeaturesInProject(TestProjectsSetupFixture.MvcProjectPath);

            Assert.True(results.FeatureStatus[mvcFeature]);
            Assert.False(results.FeatureStatus[webApiFeature]);
            Assert.False(results.FeatureStatus[sqlServerProviderFeature]);
            Assert.False(results.FeatureStatus[postgresProviderFeature]);
        }
Example #3
0
        private void InitRules(PortCoreConfiguration projectConfiguration, AnalyzerResult analyzerResult)
        {
            using var projectTypeFeatureDetector = new FeatureDetector();

            ProjectTypeFeatureResults = projectTypeFeatureDetector.DetectFeaturesInProject(analyzerResult);

            projectConfiguration.ProjectType = _solutionPort.GetProjectType(ProjectTypeFeatureResults);
            if (projectConfiguration.UseDefaultRules)
            {
                //If a rules dir was provided, copy files from that dir into the rules folder
                if (!string.IsNullOrEmpty(projectConfiguration.RulesDir))
                {
                    _solutionPort.CopyOverrideRules(projectConfiguration.RulesDir);
                }
                projectConfiguration.RulesDir = Constants.RulesDefaultPath;
                var projectResult = analyzerResult.ProjectResult;

                projectResult?.SourceFileResults?.SelectMany(s => s.References)?.Select(r => r.Namespace).Distinct().ToList().ForEach(currentReference =>
                {
                    if (currentReference != null && !ProjectReferences.Contains(currentReference))
                    {
                        ProjectReferences.Add(currentReference);
                    }
                });

                projectResult?.SourceFileResults?.SelectMany(s => s.Children.OfType <UsingDirective>())?.Select(u => u.Identifier).Distinct().ToList().ForEach(currentReference =>
                {
                    if (currentReference != null && !ProjectReferences.Contains(currentReference))
                    {
                        ProjectReferences.Add(currentReference);
                    }
                });
                ProjectReferences.Add(Constants.ProjectRecommendationFile);
            }

            _solutionPort.DownloadRecommendationFiles(ProjectReferences);
        }