예제 #1
0
        public void Init()
        {
            var mockFactory = new MockRepository(MockBehavior.Loose)
            {
                CallBase = true
            };

            m_importedProjectMetadataManagerMock = mockFactory.Create <ImportedProjectMetadataManager>(new object[1]);
            m_importHistoryManagerMock           = mockFactory.Create <ImportHistoryManager>(new object[1]);

            m_importedProjectMetadataManagerMock.Setup(x => x.GetImportedProjectMetadataByExternalId(It.IsAny <string>())).
            Returns(new ImportedProjectMetadata {
                ExternalId = "1", Project = new Project {
                    Id = 1
                }
            });

            m_filteringManager = new FilteringManager(m_importedProjectMetadataManagerMock.Object, m_importHistoryManagerMock.Object);

            var parserMock = new Mock <IProjectParser>();

            parserMock.Setup(x => x.GetPairKeyValueList(It.IsAny <ImportedRecord>())).Returns(new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("100a", "Èapek, Karel"),
                new KeyValuePair <string, string>("100a", "Hus, Jan,")
            });
            m_parser         = parserMock.Object;
            m_importedRecord = new ImportedRecord();
        }
예제 #2
0
        /// <summary>
        /// Gets all source files associated with a project.
        /// </summary>
        /// <param name="fileName">Project file name.</param>
        /// <returns>A collection of source files associated with the project.</returns>
        private ReadOnlyCollection <string> GetProjectSourceFiles(string fileName)
        {
            List <string> sourceFiles = new List <string>();

            ProjectHandler handler = GetProjectHandler(fileName);

            if (handler != null)
            {
                bool isRecognizedProject = IsRecognizedFile(fileName, handler.Configuration.ProjectExtensions);

                if (isRecognizedProject)
                {
                    IProjectParser projectParser          = handler.ProjectParser;
                    ReadOnlyCollection <string> fileNames = projectParser.Parse(fileName);
                    foreach (string sourceFile in fileNames)
                    {
                        if (IsRecognizedSourceFile(sourceFile))
                        {
                            sourceFiles.Add(sourceFile);
                        }
                    }
                }
            }

            return(sourceFiles.AsReadOnly());
        }
예제 #3
0
        private void UpdateOrDeleteProjects()
        {
            foreach (Project existingProject in this.dataContext.ListExistingProjects())
            {
                ProjectVersion projectVersion = this.dataContext.GetProjectVersion(existingProject.Id);
                IProjectParser strategy       = this.strategies.FirstOrDefault(s => s.IsExists(existingProject.Guid));

                if (strategy == null)
                {
                    if (projectVersion != null)
                    {
                        projectVersion.IsDeleted = true;
                    }
                }
                else
                {
                    if (projectVersion == null)
                    {
                        projectVersion = this.dataContext.CreateProjectVersion(existingProject);
                    }

                    strategy.UpdateProjectVersion(projectVersion, existingProject.Guid);
                    projectVersion.IsDeleted = false;
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes the extension handler.
        /// </summary>
        private void Initialize()
        {
            Type   projectParserType = null;
            string assemblyName      = _configuration.AssemblyName;

            if (string.IsNullOrEmpty(assemblyName))
            {
                _assembly = GetType().Assembly;
            }
            else
            {
                _assembly = Assembly.Load(assemblyName);
            }

            string projectParserTypeName = _configuration.ParserType;

            if (string.IsNullOrEmpty(projectParserTypeName))
            {
                projectParserType = typeof(MSBuildProjectParser);
            }
            else
            {
                projectParserType = _assembly.GetType(projectParserTypeName);
            }

            _projectParser = Activator.CreateInstance(projectParserType) as IProjectParser;
        }
예제 #5
0
        private void RunIProjectParserTest(IProjectParser parser)
        {
            string repo = GitTests.RepoPath;
            var    sci  = parser.GetSourceCodeInfo(repo, GitTests.RepoCsProj);

            Assert.IsTrue(sci.CodeFiles.Contains("ClassA.cs"));
            Assert.IsTrue(sci.CodeFiles.Contains("ClassB.cs"));
            Assert.IsTrue(sci.CodeFiles.Contains("Program.cs"));
        }
예제 #6
0
 public SolutionParser(string solutionFilePath, IProjectParser parser, ILogger logger)
 {
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
     if (string.IsNullOrWhiteSpace(solutionFilePath))
     {
         return;
     }
     _solutionFilePath = solutionFilePath;
     _projectParser    = parser;
 }
예제 #7
0
 public App(IProjectParser projectParser,
            IProjectPlanner projectPlanner,
            IReportPlanner reportPlanner,
            ILogger <App> logger)
 {
     this.projectParser  = projectParser;
     this.projectPlanner = projectPlanner;
     this.reportPlanner  = reportPlanner;
     this.logger         = logger;
 }
예제 #8
0
        public ImportedRecord SetFilterData(ImportedRecord importedRecord, IDictionary <string, List <string> > filteringExpressions,
                                            IProjectParser parser)
        {
            if (importedRecord.IsDeleted.HasValue && importedRecord.IsDeleted.Value)
            {
                importedRecord.IsSuitable = false;
                return(importedRecord);
            }

            var importedRecordDb = m_importedProjectMetadataManager.GetImportedProjectMetadataByExternalId(importedRecord.ExternalId);

            importedRecord.IsNew = importedRecordDb?.Project == null;

            if (importedRecord.IsNew)
            {
                foreach (var item in parser.GetPairKeyValueList(importedRecord))
                {
                    filteringExpressions.TryGetValue(item.Key, out var filterExpressions);
                    if (filterExpressions == null)
                    {
                        continue;
                    }

                    if (filterExpressions.Select(Regex.Escape).Select(expr => expr.Replace("%", ".*"))
                        .Any(expr => Regex.IsMatch(item.Value, expr)))
                    {
                        importedRecord.IsSuitable = true;
                        return(importedRecord);
                    }
                }

                importedRecord.IsSuitable = false;
            }
            else
            {
                var importHistory = m_importHistoryManager.GetLastImportHistoryForImportedProjectMetadata(importedRecordDb.Id);

                if (!importedRecord.TimeStamp.HasValue ||
                    importHistory == null ||
                    importHistory.Date < importedRecord.TimeStamp.Value ||
                    !string.IsNullOrEmpty(importedRecord.FaultedMessage))
                {
                    importedRecord.ProjectId = importedRecordDb.Project.Id;
                    importedRecord.ImportedProjectMetadataId = importedRecordDb.Id;
                    importedRecord.IsSuitable = true;
                }
                else
                {
                    importedRecord.IsSuitable = false;
                }
            }

            return(importedRecord);
        }
 public ProjectHookingPipeline(
     ISourceFileHooker sourceHooker,
     IGitHelpers git_h,
     IProjectReferenceInjector refInject,
     ICodeRegisterer codeReg,
     IProjectParser projParserP
     )
 {
     sourceFileHooker = sourceHooker;
     git = git_h;
     projectReferenceInjector = refInject;
     codeRegisterer           = codeReg;
     projParser = projParserP;
 }
예제 #10
0
 public ProjectPreparer(IProjectParser parser, ICache cache)
 {
     _parser = parser;
     _cache  = cache;
 }
예제 #11
0
 public FakeServiceLocator(IProjectParser parser, Func <ICache> getCache)
 {
     _parser   = parser;
     _getCache = getCache;
 }
예제 #12
0
        /// <summary>
        /// Initializes the extension handler.
        /// </summary>
        private void Initialize()
        {
            Type projectParserType = null;
            string assemblyName = _configuration.AssemblyName;
            if (string.IsNullOrEmpty(assemblyName))
            {
                _assembly = GetType().Assembly;
            }
            else
            {
                _assembly = Assembly.Load(assemblyName);
            }

            string projectParserTypeName = _configuration.ParserType;
            if (string.IsNullOrEmpty(projectParserTypeName))
            {
                projectParserType = typeof (MSBuildProjectParser);
            }
            else
            {
                projectParserType = _assembly.GetType(projectParserTypeName);
            }

            _projectParser = Activator.CreateInstance(projectParserType) as IProjectParser;
        }
 public ProjectReferenceExistsInSolutionCheck(ProjectReference[] projectsInSolution, IProjectParser parser)
 {
     this.parser = parser;
     this.projectsInSolution = projectsInSolution;
 }
 public SolutionParser(IProjectParser projectParser)
 {
     _projectParser = projectParser;
 }
예제 #15
0
 public ProjectIntegrity(IReferenceIntegrityCheck check, IProjectParser parser)
 {
     this.referenceIntegrity = new ReferenceIntegrity(check, parser.ParseBinaryReferences);
 }
 public SolutionInfoProvider(IProjectParser projectParser, ILogger logger)
 {
     _projectParser = projectParser;
     _logger        = logger;
 }
예제 #17
0
        /// <summary>
        /// Initializes the extension handler.
        /// </summary>
        private void Initialize()
        {
            //Type projectParserType = null;
            //string assemblyName = _configuration.AssemblyName;
            //if (string.IsNullOrEmpty(assemblyName))
            //{
            //    _assembly = GetType().Assembly;
            //}
            //else
            //{
            //    _assembly = Assembly.Load(assemblyName);
            //}

            //string projectParserTypeName = _configuration.ParserType;
            //if (string.IsNullOrEmpty(projectParserTypeName))
            //{
            //    projectParserType = typeof(MSBuildProjectParser);
            //}
            //else
            //{
            //    projectParserType = _assembly.GetType(projectParserTypeName);
            //}

            //_projectParser = Activator.CreateInstance(projectParserType) as IProjectParser;

            _projectParser = new NArrange.Core.MSBuildProjectParser();
        }
예제 #18
0
 public SolutionIntegrityCheck(IFileSystem fileSystem, ProjectReference[] projectsInSolution, IProjectParser parser)
 {
     this.refExists = new ReferenceExistsCheck(fileSystem);
     this.refInSolution = new ProjectReferenceExistsInSolutionCheck(projectsInSolution, parser);
 }