コード例 #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = 13;
         hashCode = (hashCode * 17) ^ TypeOfFileSearch.GetHashCode();
         hashCode = (hashCode * 17) ^ FilePattern?.GetHashCode() ?? 5;
         hashCode = (hashCode * 17) ^ IgnoreFilePattern?.GetHashCode() ?? 5;
         hashCode = (hashCode * 17) ^ TypeOfSearch.GetHashCode();
         hashCode = (hashCode * 17) ^ SearchFor?.GetHashCode() ?? 5;
         hashCode = (hashCode * 17) ^ ReplaceWith?.GetHashCode() ?? 5;
         hashCode = (hashCode * 17) ^ CaseSensitive.GetHashCode();
         hashCode = (hashCode * 17) ^ WholeWord.GetHashCode();
         hashCode = (hashCode * 17) ^ Multiline.GetHashCode();
         hashCode = (hashCode * 17) ^ Singleline.GetHashCode();
         hashCode = (hashCode * 17) ^ BooleanOperators.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeSubfolders.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeHidden.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeBinary.GetHashCode();
         hashCode = (hashCode * 17) ^ MaxSubfolderDepth.GetHashCode();
         hashCode = (hashCode * 17) ^ UseGitignore.GetHashCode();
         hashCode = (hashCode * 17) ^ SkipRemoteCloudStorageFiles.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeArchive.GetHashCode();
         hashCode = (hashCode * 17) ^ FollowSymlinks.GetHashCode();
         hashCode = (hashCode * 17) ^ CodePage.GetHashCode();
         hashCode = (hashCode * 17) ^ ApplyFileSourceFilters.GetHashCode();
         hashCode = (hashCode * 17) ^ ApplyFilePropertyFilters.GetHashCode();
         hashCode = (hashCode * 17) ^ ApplyContentSearchFilters.GetHashCode();
         return(hashCode);
     }
 }
コード例 #2
0
        public void StrykerCLI_WithConfigFile_ShouldStartStrykerWithConfigFileOptions(string argName)
        {
            var            filePattern   = new FilePattern(Glob.Parse(FilePathUtils.NormalizePathSeparators("**/Test.cs")), true, new[] { TextSpan.FromBounds(1, 100), TextSpan.FromBounds(200, 300) });
            StrykerOptions actualOptions = null;
            var            runResults    = new StrykerRunResult(new StrykerOptions(), 0.3);

            var mock = new Mock <IStrykerRunner>(MockBehavior.Strict);

            mock.Setup(x => x.RunMutationTest(It.IsAny <StrykerOptions>(), It.IsAny <IEnumerable <LogMessage> >()))
            .Callback <StrykerOptions, IEnumerable <LogMessage> >((c, m) => actualOptions = c)
            .Returns(runResults)
            .Verifiable();

            var target = new StrykerCLI(mock.Object);

            target.Run(new string[] { argName, "filled-stryker-config.json" });

            mock.VerifyAll();

            actualOptions.DevMode.ShouldBe(true);
            actualOptions.AdditionalTimeoutMS.ShouldBe(9999);
            actualOptions.LogOptions.LogLevel.ShouldBe(LogEventLevel.Verbose);
            actualOptions.ProjectUnderTestNameFilter.ShouldBe("ExampleProject.csproj");
            actualOptions.Reporters.ShouldHaveSingleItem();
            actualOptions.Reporters.ShouldContain(Reporter.ConsoleReport);
            actualOptions.ConcurrentTestRunners.ShouldBe(1);
            actualOptions.Thresholds.Break.ShouldBe(20);
            actualOptions.Thresholds.Low.ShouldBe(30);
            actualOptions.Thresholds.High.ShouldBe(40);
            actualOptions.FilePatterns.Count().ShouldBe(2);
            actualOptions.FilePatterns.ShouldContain(filePattern);
            actualOptions.Optimizations.ShouldBe(OptimizationFlags.CoverageBasedTest | OptimizationFlags.AbortTestOnKill);
        }
コード例 #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = 13;
         hashCode = (hashCode * 17) ^ TypeOfFileSearch.GetHashCode();
         hashCode = (hashCode * 17) ^ FilePattern.GetHashCode();
         hashCode = (hashCode * 17) ^ IgnoreFilePattern.GetHashCode();
         hashCode = (hashCode * 17) ^ TypeOfSearch.GetHashCode();
         hashCode = (hashCode * 17) ^ SearchFor.GetHashCode();
         hashCode = (hashCode * 17) ^ ReplaceWith.GetHashCode();
         hashCode = (hashCode * 17) ^ CaseSensitive.GetHashCode();
         hashCode = (hashCode * 17) ^ WholeWord.GetHashCode();
         hashCode = (hashCode * 17) ^ Multiline.GetHashCode();
         hashCode = (hashCode * 17) ^ Singleline.GetHashCode();
         hashCode = (hashCode * 17) ^ BooleanOperators.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeSubfolders.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeHidden.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeBinary.GetHashCode();
         hashCode = (hashCode * 17) ^ MaxSubfolderDepth.GetHashCode();
         hashCode = (hashCode * 17) ^ UseGitignore.GetHashCode();
         hashCode = (hashCode * 17) ^ IncludeArchive.GetHashCode();
         hashCode = (hashCode * 17) ^ FollowSymlinks.GetHashCode();
         hashCode = (hashCode * 17) ^ CodePage.GetHashCode();
         return(hashCode);
     }
 }
コード例 #4
0
ファイル: StrykerCLITests.cs プロジェクト: wiciok/stryker-net
        public void StrykerCLI_WithFilesToExcludeSet_ShouldPassFilesToExcludeToStryker(string argName)
        {
            var            mock          = new Mock <IStrykerRunner>(MockBehavior.Strict);
            StrykerOptions actualOptions = null;
            var            runResults    = new StrykerRunResult(new StrykerOptions(), 0.1);

            mock.Setup(x => x.RunMutationTest(It.IsAny <StrykerOptions>(), It.IsAny <IEnumerable <LogMessage> >()))
            .Callback <StrykerOptions, IEnumerable <LogMessage> >((c, m) => actualOptions = c)
            .Returns(runResults)
            .Verifiable();

            var target = new StrykerCLI(mock.Object);

            target.Run(new[] { argName, @"['./StartUp.cs','./ExampleDirectory/Recursive.cs', './ExampleDirectory/Recursive2.cs']" });

            var firstFileToExclude  = FilePattern.Parse("!StartUp.cs");
            var secondFileToExclude = FilePattern.Parse("!ExampleDirectory/Recursive.cs");
            var thirdFileToExclude  = FilePattern.Parse("!ExampleDirectory/Recursive2.cs");

            var filePatterns = actualOptions.FilePatterns.ToArray();

            filePatterns.Count(x => x.IsExclude).ShouldBe(3);
            filePatterns.ShouldContain(firstFileToExclude);
            filePatterns.ShouldContain(secondFileToExclude);
            filePatterns.ShouldContain(thirdFileToExclude);
        }
コード例 #5
0
ファイル: WeavingEntityTask.cs プロジェクト: zhukaixy/Scut
        private void SearchForPropertiesAndAddMSIL()
        {
            string path = "";

            try
            {
                bool hasBuild = false;
                FilePattern = (FilePattern ?? "*.dll");
                if (!FilePattern.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase))
                {
                    FilePattern = FilePattern + ".dll";
                }
                var pathList = Directory.GetFiles(SolutionDir, FilePattern, SearchOption.AllDirectories);
                foreach (string assemblyPath in pathList)
                {
                    path = Path.GetFullPath(assemblyPath);
                    if (AssemblyBuilder.BuildToFile(path, SolutionDir))
                    {
                        hasBuild = true;
                    }
                }
                if (!hasBuild)
                {
                    Log.LogWarning("The model:\"" + FilePattern + "\" has not be builded.");
                }
            }
            catch (Exception ex)
            {
                Log.LogError("The model:\"" + FilePattern + "\" build error:" + ex.Message + "\r\n" + ex.StackTrace);
            }
        }
コード例 #6
0
ファイル: StrykerCLITests.cs プロジェクト: wiciok/stryker-net
        public void StrykerCLI_WithFilePatternSet_ShouldPassFilePatternSetToStryker(string argName)
        {
            var            mock          = new Mock <IStrykerRunner>(MockBehavior.Strict);
            StrykerOptions actualOptions = null;
            var            runResults    = new StrykerRunResult(new StrykerOptions(), 0.1);

            mock.Setup(x => x.RunMutationTest(It.IsAny <StrykerOptions>(), It.IsAny <IEnumerable <LogMessage> >()))
            .Callback <StrykerOptions, IEnumerable <LogMessage> >((c, m) => actualOptions = c)
            .Returns(runResults)
            .Verifiable();

            var target = new StrykerCLI(mock.Object);

            target.Run(new[] { argName, @"['**/*Service.cs','!**/MySpecialService.cs', '**/MyOtherService.cs{1..10}{32..45}']" });

            var firstFileToExclude  = FilePattern.Parse("**/*Service.cs");
            var secondFileToExclude = FilePattern.Parse("!**/MySpecialService.cs");
            var thirdFileToExclude  = FilePattern.Parse("**/MyOtherService.cs{1..10}{32..45}");

            var filePatterns = actualOptions.FilePatterns.ToArray();

            filePatterns.Length.ShouldBe(3);
            filePatterns.ShouldContain(firstFileToExclude);
            filePatterns.ShouldContain(secondFileToExclude);
            filePatterns.ShouldContain(thirdFileToExclude);
        }
コード例 #7
0
ファイル: FilePatternTests.cs プロジェクト: wjeon/soothsayer
        public void environment_pattern_matches_environment_targetted_script()
        {
            var pattern = FilePattern.ForEnvironment("yaks");

            Assert.That("somescript.yaks.sql".Matches(pattern));
            Assert.That("somescript.geese.sql".Matches(pattern), Is.False);
        }
コード例 #8
0
 private void UpdateFilePatternStatus(DataGridView DataGridView, int RowIndex)
 {
     if (RowIndex.IsBetween(0, DataGridView.Rows.Count - 1))
     {
         FilePattern F = new FilePattern((string)DataGridView[0, RowIndex].Value);
         DataGridView[1, RowIndex].Value = (F.IsValid ? "OK" : "Invalid file pattern");
     }
 }
コード例 #9
0
        public Project LoadProject(State state, string projectKey)
        {
            var root = state.RootPath;
            var path = FolderPattern.GetPathForProjectRoot(root);;
            var file = FilePattern.GetFileName(projectKey, FilePattern.ProjectFileEnding);

            return(Load(path, file));
        }
コード例 #10
0
        public void SaveExport(State state, Project project, Export export)
        {
            var root = state.RootPath;
            var path = FolderPattern.GetPathForProject(root, project.GetFileName());
            var file = FilePattern.GetFileName(export.GetFileName(), FilePattern.DataExportFileEnding);

            Write(path, file, export.data);
        }
コード例 #11
0
        public override void OnOpened(FilePattern switchContextPattern)
        {
            var actionNode = GetActionNodeFromName(switchContextPattern.Action);

            if (actionNode != null)
            {
                ((TextSelection)Context.Document.Selection).MoveToAbsoluteOffset(actionNode.SpanStart);
            }
        }
コード例 #12
0
ファイル: PathTransformer.cs プロジェクト: raulgarciamsft/ql
 public bool Matches(string path, [NotNullWhen(true)] out string?transformed)
 {
     if (FilePattern.Matches(filePatterns, path, out var suffix))
     {
         transformed = FileUtils.ConvertToUnix(name) + suffix;
         return(true);
     }
     transformed = null;
     return(false);
 }
コード例 #13
0
        /// <summary>
        /// Gets all the runtime dependencies Copies all the runtime dependencies from any modules in
        /// </summary>
        /// <param name="RuntimeDependencies">The output list of runtime dependencies, mapping target file to type</param>
        /// <param name="TargetFileToSourceFile">Map of target files to source files that need to be copied</param>
        /// <param name="ExeDir">Output directory for the executable</param>
        public void PrepareRuntimeDependencies(List <RuntimeDependency> RuntimeDependencies, Dictionary <FileReference, FileReference> TargetFileToSourceFile, DirectoryReference ExeDir)
        {
            foreach (UEBuildModule Module in Modules)
            {
                foreach (ModuleRules.RuntimeDependency Dependency in Module.Rules.RuntimeDependencies.Inner)
                {
                    if (Dependency.SourcePath == null)
                    {
                        // Expand the target path
                        string ExpandedPath = Module.ExpandPathVariables(Dependency.Path, OutputDir, ExeDir);
                        if (FileFilter.FindWildcardIndex(ExpandedPath) == -1)
                        {
                            RuntimeDependencies.Add(new RuntimeDependency(new FileReference(ExpandedPath), Dependency.Type));
                        }
                        else
                        {
                            RuntimeDependencies.AddRange(FileFilter.ResolveWildcard(ExpandedPath).Select(x => new RuntimeDependency(x, Dependency.Type)));
                        }
                    }
                    else
                    {
                        // Parse the source and target patterns
                        FilePattern SourcePattern = new FilePattern(UnrealBuildTool.EngineSourceDirectory, Module.ExpandPathVariables(Dependency.SourcePath, OutputDir, ExeDir));
                        FilePattern TargetPattern = new FilePattern(UnrealBuildTool.EngineSourceDirectory, Module.ExpandPathVariables(Dependency.Path, OutputDir, ExeDir));

                        // Resolve all the wildcards between the source and target paths
                        Dictionary <FileReference, FileReference> Mapping;
                        try
                        {
                            Mapping = FilePattern.CreateMapping(null, ref SourcePattern, ref TargetPattern);
                        }
                        catch (FilePatternException Ex)
                        {
                            ExceptionUtils.AddContext(Ex, "while creating runtime dependencies for module '{0}'", Module.Name);
                            throw;
                        }

                        // Add actions to copy everything
                        foreach (KeyValuePair <FileReference, FileReference> Pair in Mapping)
                        {
                            FileReference ExistingSourceFile;
                            if (!TargetFileToSourceFile.TryGetValue(Pair.Key, out ExistingSourceFile))
                            {
                                TargetFileToSourceFile[Pair.Key] = Pair.Value;
                                RuntimeDependencies.Add(new RuntimeDependency(Pair.Key, Dependency.Type));
                            }
                            else if (ExistingSourceFile != Pair.Value)
                            {
                                throw new BuildException("Runtime dependency '{0}' is configured to be staged from '{1}' and '{2}'", Pair.Key, Pair.Value, ExistingSourceFile);
                            }
                        }
                    }
                }
            }
        }
コード例 #14
0
        [InlineData("{10..19}{20..30}", 15, 25, false)] // Two spans with gab; start and end of span are in the spans
        public void IsMatch_should_match_textSpans(string spanPattern, int spanStart, int spanEnd, bool isMatch)
        {
            // Arrange
            var sut = FilePattern.Parse("*.*" + spanPattern);

            // Act
            var result = sut.IsMatch($"test.cs", TextSpan.FromBounds(spanStart, spanEnd));

            // Assert
            result.ShouldBe(isMatch);
        }
コード例 #15
0
ファイル: BookmarksViewModel.cs プロジェクト: xyztai/dnGrep
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = 13;
         hashCode = (hashCode * 397) ^ FilePattern.GetHashCode();
         hashCode = (hashCode * 397) ^ SearchFor.GetHashCode();
         hashCode = (hashCode * 397) ^ ReplaceWith.GetHashCode();
         return(hashCode);
     }
 }
コード例 #16
0
        public void IsMatch_should_match_glob_pattern(string file, string glob, bool isMatch)
        {
            // Arrange
            var textSpan = new TextSpan(0, 1);
            var sut      = new FilePattern(Glob.Parse(glob), false, new[] { textSpan });

            // Act
            var result = sut.IsMatch(file, textSpan);

            // Assert
            result.ShouldBe(isMatch);
        }
コード例 #17
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            // Inputs
            var folderpath  = FolderPath.Get(context);
            var filepattern = FilePattern.Get(context);

            string[] filepath = Directory.GetFiles(@folderpath, filepattern);

            // Outputs
            return((ctx) => {
                FilePath.Set(ctx, filepath);
            });
        }
コード例 #18
0
        public void TestRegexCompilation()
        {
            var fp = new FilePattern("/hadoop*");

            Assert.Equal("^hadoop[^/]*.*", fp.RegexPattern);
            fp = new FilePattern("**/org/apache/hadoop");
            Assert.Equal("^.*/org/apache/hadoop.*", fp.RegexPattern);
            fp = new FilePattern("hadoop-common/**/test//    ");
            Assert.Equal("^hadoop-common/.*/test(?<doubleslash>/).*", fp.RegexPattern);
            fp = new FilePattern(@"-C:\agent\root\asdf//");
            Assert.Equal("^C:/agent/root/asdf(?<doubleslash>/).*", fp.RegexPattern);
            fp = new FilePattern(@"-C:\agent+\[root]\asdf//");
            Assert.Equal(@"^C:/agent\+/\[root]/asdf(?<doubleslash>/).*", fp.RegexPattern);
        }
コード例 #19
0
        /// <summary>
        /// Gets all the runtime dependencies Copies all the runtime dependencies from any modules in
        /// </summary>
        /// <param name="RuntimeDependencies">The output list of runtime dependencies, mapping target file to type</param>
        /// <param name="SourceFiles">Receives the list of source files that were copied</param>
        /// <param name="ActionGraph">Actions to be executed</param>
        public IEnumerable <FileItem> PrepareRuntimeDependencies(List <RuntimeDependency> RuntimeDependencies, List <FileReference> SourceFiles, ActionGraph ActionGraph)
        {
            List <FileItem> CopiedFiles = new List <FileItem>();

            foreach (UEBuildModule Module in Modules)
            {
                foreach (ModuleRules.RuntimeDependency Dependency in Module.Rules.RuntimeDependencies.Inner)
                {
                    if (Dependency.SourcePath == null)
                    {
                        // Expand the target path
                        string ExpandedPath = Module.ExpandPathVariables(Dependency.Path, this);
                        if (FileFilter.FindWildcardIndex(ExpandedPath) == -1)
                        {
                            RuntimeDependencies.Add(new RuntimeDependency(new FileReference(ExpandedPath), Dependency.Type));
                        }
                        else
                        {
                            RuntimeDependencies.AddRange(FileFilter.ResolveWildcard(ExpandedPath).Select(x => new RuntimeDependency(x, Dependency.Type)));
                        }
                    }
                    else
                    {
                        // Parse the source and target patterns
                        FilePattern SourcePattern = new FilePattern(UnrealBuildTool.EngineSourceDirectory, Module.ExpandPathVariables(Dependency.SourcePath, this));
                        FilePattern TargetPattern = new FilePattern(UnrealBuildTool.EngineSourceDirectory, Module.ExpandPathVariables(Dependency.Path, this));

                        // Resolve all the wildcards between the source and target paths
                        Dictionary <FileReference, FileReference> Mapping;
                        try
                        {
                            Mapping = FilePattern.CreateMapping(null, ref SourcePattern, ref TargetPattern);
                        }
                        catch (FilePatternException Ex)
                        {
                            throw new BuildException(Ex, "While creating runtime dependencies for module {0}", Module.Name);
                        }

                        // Add actions to copy everything
                        foreach (KeyValuePair <FileReference, FileReference> Pair in Mapping)
                        {
                            CopiedFiles.Add(CreateCopyAction(Pair.Value, Pair.Key, ActionGraph));
                            SourceFiles.Add(Pair.Value);
                            RuntimeDependencies.Add(new RuntimeDependency(Pair.Key, Dependency.Type));
                        }
                    }
                }
            }
            return(CopiedFiles);
        }
コード例 #20
0
        public void Parse_should_parse_correctly(string spanPattern, string glob, bool isExclude, int[] spans)
        {
            // Arrange
            var textSpans = Enumerable.Range(0, spans.Length)
                            .GroupBy(i => Math.Floor(i / 2d))
                            .Select(x => TextSpan.FromBounds(spans[x.First()], spans[x.Skip(1).First()]));

            // Act
            var result = FilePattern.Parse(spanPattern);

            // Assert
            result.Glob.ToString().ShouldBe(FilePathUtils.NormalizePathSeparators(glob));
            result.IsExclude.ShouldBe(isExclude);
            result.TextSpans.SequenceEqual(textSpans).ShouldBe(true);
        }
コード例 #21
0
ファイル: FilesManager.cs プロジェクト: carlos-takeapps/moira
        public static FileInfo[] GetMatchingFiles(string path, FilePattern pattern)
        {
            FileInfo[] result = null;

            if (pattern.IsRegEx)
            {
                result = GetRegexMatchingFiles(path, pattern.Pattern);
            }
            else
            {
                result = GetStringMatchingFiles(path, pattern.Pattern);
            }

            return(result);
        }
コード例 #22
0
        //  -------------------------------------------------------------------
        private string[] VerifyRequiredFiles(ITargetAssignment assignment,
                                             ISubmittableItem[] items)
        {
            Dictionary <string, bool> requiredFiles =
                new Dictionary <string, bool>();

            string[] patterns = assignment.AllRequiredFiles;
            foreach (string pattern in patterns)
            {
                requiredFiles.Add(pattern, false);
            }

            foreach (ISubmittableItem item in
                     new DepthFirstTraversal <ISubmittableItem>(items,
                                                                delegate(ISubmittableItem i) { return(i.Children); }))
            {
                if (item.Kind == SubmittableItemKind.File)
                {
                    foreach (string reqPattern in patterns)
                    {
                        FilePattern pattern = new FilePattern(reqPattern);
                        if (pattern.Matches(item.Filename))
                        {
                            requiredFiles[reqPattern] = true;
                        }
                    }
                }
            }

            List <string> missingFiles = new List <string>();

            foreach (string requiredFile in requiredFiles.Keys)
            {
                if (requiredFiles[requiredFile] == false)
                {
                    missingFiles.Add(requiredFile);
                }
            }

            if (missingFiles.Count == 0)
            {
                return(null);
            }
            else
            {
                return(missingFiles.ToArray());
            }
        }
コード例 #23
0
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        /// <returns>True if the task succeeded</returns>
        public override bool Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Parse all the source patterns
            FilePattern SourcePattern = new FilePattern(CommandUtils.RootDirectory, Parameters.From);

            // Parse the target pattern
            FilePattern TargetPattern = new FilePattern(CommandUtils.RootDirectory, Parameters.To);

            // Apply the filter to the source files
            HashSet <FileReference> Files = null;

            if (!String.IsNullOrEmpty(Parameters.Files))
            {
                SourcePattern = SourcePattern.AsDirectoryPattern();
                Files         = ResolveFilespec(SourcePattern.BaseDirectory, Parameters.Files, TagNameToFileSet);
            }

            // Build the file mapping
            Dictionary <FileReference, FileReference> TargetFileToSourceFile;

            if (!FilePattern.TryCreateMapping(Files, SourcePattern, TargetPattern, out TargetFileToSourceFile))
            {
                return(false);
            }

            // Check we got some files
            if (TargetFileToSourceFile.Count == 0)
            {
                CommandUtils.Log("No files found matching '{0}'", SourcePattern);
                return(true);
            }

            // Copy them all
            KeyValuePair <FileReference, FileReference>[] FilePairs = TargetFileToSourceFile.ToArray();
            CommandUtils.Log("Copying {0} file{1} from {2} to {3}...", FilePairs.Length, (FilePairs.Length == 1)? "" : "s", SourcePattern.BaseDirectory, TargetPattern.BaseDirectory);
            CommandUtils.ThreadedCopyFiles(FilePairs.Select(x => x.Value.FullName).ToList(), FilePairs.Select(x => x.Key.FullName).ToList(), bQuiet: true);

            // Update the list of build products
            BuildProducts.UnionWith(TargetFileToSourceFile.Keys);

            // Apply the optional output tag to them
            foreach (string TagName in FindTagNamesFromList(Parameters.Tag))
            {
                FindOrAddTagSet(TagNameToFileSet, TagName).UnionWith(TargetFileToSourceFile.Keys);
            }
            return(true);
        }
コード例 #24
0
        public void TestMatching()
        {
            var fp1      = new FilePattern(@"C:\agent\root\abc//");
            var fp2      = new FilePattern(@"C:\agent\root\def//ghi");
            var patterns = new[] { fp1, fp2 };

            var success = FilePattern.Matches(patterns, @"C:\agent\root\abc\file.cs", out var s);

            Assert.True(success);
            Assert.Equal("/file.cs", s);

            success = FilePattern.Matches(patterns, @"C:\agent\root\def\ghi\file.cs", out s);
            Assert.True(success);
            Assert.Equal("/ghi/file.cs", s);

            success = FilePattern.Matches(patterns, @"C:\agent\root\def\file.cs", out _);
            Assert.False(success);
        }
コード例 #25
0
ファイル: AssetTestSec.cs プロジェクト: TyoukabuN/Code_F
    public static string GetPatternByProperties(FilePattern p)
    {
        Type enumType = p.GetType();               //得到enum的类型

        FieldInfo[] fields = enumType.GetFields(); //获取enum下的所有共有字段
        foreach (var field in fields)              //遍历字段
        {
            if (field.Name.Equals(p.ToString()))   //判断出与arg相同的字段
            {
                //获取该字段上的Pattern属性
                object[] attributes = field.GetCustomAttributes(typeof(PatternAttribute), true);
                if (attributes.Length > 0)
                {
                    return(((PatternAttribute)attributes[0]).Pattern);
                }
            }
        }
        return(string.Empty);
    }
コード例 #26
0
ファイル: MoveTask.cs プロジェクト: nikimar1/cloneofg4g2019
        /// <summary>
        /// Execute the task.
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="BuildProducts">Set of build products produced by this node.</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include</param>
        public override void Execute(JobContext Job, HashSet <FileReference> BuildProducts, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Parse all the source patterns
            FilePattern SourcePattern = new FilePattern(CommandUtils.RootDirectory, Parameters.From);

            // Parse the target pattern
            FilePattern TargetPattern = new FilePattern(CommandUtils.RootDirectory, Parameters.To);

            // Apply the filter to the source files
            HashSet <FileReference> Files = null;

            if (!String.IsNullOrEmpty(Parameters.Files))
            {
                SourcePattern = SourcePattern.AsDirectoryPattern();
                Files         = ResolveFilespec(SourcePattern.BaseDirectory, Parameters.Files, TagNameToFileSet);
            }

            // Build the file mapping
            Dictionary <FileReference, FileReference> TargetFileToSourceFile = FilePattern.CreateMapping(Files, ref SourcePattern, ref TargetPattern);

            // Check we got some files
            if (TargetFileToSourceFile.Count == 0)
            {
                CommandUtils.LogInformation("No files found matching '{0}'", SourcePattern);
                return;
            }

            // Copy them all
            CommandUtils.LogInformation("Moving {0} file{1} from {2} to {3}...", TargetFileToSourceFile.Count, (TargetFileToSourceFile.Count == 1)? "" : "s", SourcePattern.BaseDirectory, TargetPattern.BaseDirectory);
            CommandUtils.ParallelMoveFiles(TargetFileToSourceFile.Select(x => new KeyValuePair <FileReference, FileReference>(x.Value, x.Key)));

            // Update the list of build products
            BuildProducts.UnionWith(TargetFileToSourceFile.Keys);

            // Apply the optional output tag to them
            foreach (string TagName in FindTagNamesFromList(Parameters.Tag))
            {
                FindOrAddTagSet(TagNameToFileSet, TagName).UnionWith(TargetFileToSourceFile.Keys);
            }
        }
コード例 #27
0
        IEnumerable <string> GetFilenames(IDirectory directory)
        {
            IEnumerable <string> filenames;

            if (string.IsNullOrEmpty(FilePattern))
            {
                filenames = null; // directory.GetFiles("*", SearchOption);
            }
            else
            {
                var patterns = FilePattern.Split(';', ',');
                filenames = null;
                //filenames = patterns.SelectMany(
                //    pattern => directory.GetFiles(pattern, SearchOption)
                //);
            }

            if (Exclude != null)
            {
                filenames = filenames.Where(f => Exclude.IsMatch(f) == false);
            }
            return(filenames);
        }
コード例 #28
0
ファイル: FTPDownloader.cs プロジェクト: rkm/RDMP
        protected SkipReason GetSkipActionForFile(string file, ILoadDirectory destination)
        {
            if (file.StartsWith("."))
            {
                return(SkipReason.IsImaginaryFile);
            }

            //if there is a regex pattern
            if (FilePattern != null)
            {
                if (!FilePattern.IsMatch(file))            //and it does not match
                {
                    return(SkipReason.DidNotMatchPattern); //skip because it did not match pattern
                }
            }
            //if the file on the FTP already exists in the forLoading directory, skip it
            if (destination.ForLoading.GetFiles(file).Any())
            {
                return(SkipReason.InForLoading);
            }


            return(SkipReason.DoNotSkip);
        }
コード例 #29
0
        private void SaveRecordInternal(string pathForProject, Record record)
        {
            var file = FilePattern.GetFileName(record.GetFileName(), FilePattern.DataFileEnding);

            Save(pathForProject, file, record);
        }
コード例 #30
0
 protected override string GetFilePathFromPattern(FilePattern pattern, IConfiguration configuration)
 {
     return(Path.Combine(pattern.RootDirectory,
                         $@"{configuration.TSRootPath}{pattern.ModulePath}{pattern.Controller}\{pattern.Action}.ts"));
 }
コード例 #31
0
        //  -------------------------------------------------------------------
        private string[] VerifyRequiredFiles(ITargetAssignment assignment,
			ISubmittableItem[] items)
        {
            Dictionary<string, bool> requiredFiles =
                new Dictionary<string, bool>();

            string[] patterns = assignment.AllRequiredFiles;
            foreach(string pattern in patterns)
                requiredFiles.Add(pattern, false);

            foreach (ISubmittableItem item in
                new DepthFirstTraversal<ISubmittableItem>(items,
                delegate(ISubmittableItem i) { return i.Children; }))
            {
                if (item.Kind == SubmittableItemKind.File)
                {
                    foreach (string reqPattern in patterns)
                    {
                        FilePattern pattern = new FilePattern(reqPattern);
                        if(pattern.Matches(item.Filename))
                        {
                            requiredFiles[reqPattern] = true;
                        }
                    }
                }
            }

            List<string> missingFiles = new List<string>();
            foreach (string requiredFile in requiredFiles.Keys)
            {
                if (requiredFiles[requiredFile] == false)
                {
                    missingFiles.Add(requiredFile);
                }
            }

            if (missingFiles.Count == 0)
            {
                return null;
            }
            else
            {
                return missingFiles.ToArray();
            }
        }
コード例 #32
0
        public virtual bool IsFileExcluded(string projectRelativePath)
        {
            bool localExclude = false;
            bool localInclude = false;

            // Check to see if the file is excluded locally.
            string[] excludes = ExcludedFiles;
            foreach (string exclude in excludes)
            {
                FilePattern pattern = new FilePattern(exclude);

                if (pattern.Matches(projectRelativePath))
                {
                    localExclude = true;
                    break;
                }
            }

            // Check to see if the file is explicitly included
            // locally.
            string[] includes = IncludedFiles;
            foreach (string include in includes)
            {
                FilePattern pattern = new FilePattern(include);

                if (pattern.Matches(projectRelativePath))
                {
                    localInclude = true;
                    break;
                }
            }

            if (localInclude && localExclude)
            {
                if (ambiguityResolution == AmbiguityResolution.Exclude)
                    return true;
                else
                    return false;
            }
            else if (localExclude)
            {
                return true;
            }
            else if (localInclude)
            {
                return false;
            }

            // If no explicit mention of the file was found,
            // try going up the assignment tree.
            if (parent != null)
                return parent.IsFileExcluded(projectRelativePath);
            else
            {
                if (includes.Length == 0)
                    return false;
                else
                    return true;
            }
        }