Example #1
0
        public IEnumerable <string> GetFiles(string root, string pattern, IncludeExcludeCollection sourceFileFilters)
        {
            root = root.Trim().ToLower().Replace('/', '\\').Trim('\\') + '\\';
            var excludeIncludeElements = sourceFileFilters.Cast <IncludeExcludeElement>();

            return(Directory.GetFiles(root, pattern, SearchOption.AllDirectories).Where(fn => Filter(root, fn, excludeIncludeElements)));
        }
        public void TestGetFiles(string includes, string excludes, int expectedCount)
        {
            var includeSplit             = includes.Split(';');
            var excludeSplit             = excludes.Split(';');
            var includeExcludeCollection = new IncludeExcludeCollection();

            Assert.AreEqual(includeSplit.Count(), excludeSplit.Count());
            for (int index = 0; index < includeSplit.Length; index++)
            {
                includeExcludeCollection.Add(new IncludeExcludeElement {
                    Include = includeSplit[index], Exclude = excludeSplit[index]
                });
            }

            string tempRoot = null;

            try
            {
                tempRoot = TestUtils.CreateFoldersAndFiles(TestUtils.MockFileSystemDefinition, "cs");
                var files = new FileSystemHelper().GetFiles(tempRoot, "*.cs", includeExcludeCollection);
                Assert.AreEqual(expectedCount, files.Count());
            }
            finally
            {
                if (tempRoot != null)
                {
                    TestUtils.DeleteFolder(tempRoot);
                }
            }
        }
Example #3
0
 protected TransformRule(IncludeExcludeCollection sourceFileFilters, IFileSystemHelper fileSystemHelper, string fileNamePattern = "*.cs", bool isBackupEnabled = true)
 {
     _isBackupEnabled   = isBackupEnabled;
     _fileNamePattern   = fileNamePattern;
     _fileSystemHelper  = fileSystemHelper;
     _sourceFileFilters = sourceFileFilters;
 }
        protected RefactorRule(IncludeExcludeCollection sourceFileFilters, IFileSystemHelper fileSystemHelper, string fileNamePattern = "*.cs", bool isBackupEnabled = true)
            : base(sourceFileFilters, fileSystemHelper, fileNamePattern, isBackupEnabled)
        {
            var workspace = new CustomWorkspace();
            var solution  = workspace.CurrentSolution;

            _project  = solution.AddProject("dummyProjectName", "dummyAssemblyName", LanguageNames.CSharp);
            Parameter = new ExpandoObject();
        }
Example #5
0
 public ReformatRule(string optionsFilePath, IncludeExcludeCollection sourceFileFilters, IFileSystemHelper fileSystemHelper, string fileNamePattern = "*.cs", bool isBackupEnabled = true)
     : base(sourceFileFilters, fileSystemHelper, fileNamePattern, isBackupEnabled)
 {
     _options = CSharpFormattingProperties.GetOptions(optionsFilePath);
 }
 public RenamePrivateFieldsRefactorRule(string find, string replace, IncludeExcludeCollection sourceFileFilters, IFileSystemHelper fileSystemHelper, string fileNamePattern = "*.cs", bool isBackupEnabled = true)
     : base(sourceFileFilters, fileSystemHelper, fileNamePattern, isBackupEnabled)
 {
     Parameter.Find    = find;
     Parameter.Replace = replace;
 }
Example #7
0
 public RemoveRedundantThisQualifierRule(IncludeExcludeCollection sourceFileFilters, IFileSystemHelper fileSystemHelper, string fileNamePattern = "*.cs", bool isBackupEnabled = true) : base(sourceFileFilters, fileSystemHelper, fileNamePattern, isBackupEnabled)
 {
 }