Ejemplo n.º 1
0
        public override bool Execute()
        {
            var path    = Path.Replace('\\', '/').TrimEnd('/');
            var exclude = new HashSet <string> ();
            var items   = new List <ITaskItem> ();
            IEnumerable <string> files;
            SearchOption         option;

            if (!string.IsNullOrEmpty(Option))
            {
                if (!Enum.TryParse(Option, out option))
                {
                    Log.LogError(MSBStrings.E0050, Option);
                    return(false);
                }
            }
            else
            {
                option = SearchOption.TopDirectoryOnly;
            }

            if (!Directory.Exists(path))
            {
                Files = items.ToArray();

                return(!Log.HasLoggedErrors);
            }

            if (!string.IsNullOrEmpty(Pattern))
            {
                files = Directory.EnumerateFiles(path, Pattern, option);
            }
            else
            {
                files = Directory.EnumerateFiles(path, "*.*", option);
            }

            if (!string.IsNullOrEmpty(Exclude))
            {
                foreach (var rpath in Exclude.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    var full = System.IO.Path.Combine(path, rpath.Replace('\\', '/'));
                    exclude.Add(full);
                }
            }

            foreach (var file in files)
            {
                if (!exclude.Contains(file))
                {
                    items.Add(new TaskItem(file));
                }
            }

            Files = items.ToArray();

            return(!Log.HasLoggedErrors);
        }
Ejemplo n.º 2
0
        private IEnumerable <FieldInfo> GetEnumFieldsAndValues(Type type)
        {
            IEnumerable <FieldInfo> fields = type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

            if (!string.IsNullOrWhiteSpace(Exclude))
            {
                var excludedEnums = Exclude?.Split(',').Select(x => Enum.Parse(type, x));
                var hash          = new HashSet <object>(excludedEnums);
                fields = fields.Where(field => !hash.Contains(field.GetValue(null)));
            }

            return(fields);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 排除预定义
        /// </summary>
        /// <param name="cache"></param>
        protected void ExcludeFile(Dictionary <string, FileDetailInfo> cache)
        {
            Console.WriteLine("");

            //排除预定义的后缀
            var array =
                Exclude.Split(',')
                .Where(p => !string.IsNullOrEmpty(p))
                .Select(p => "." + p.TrimStart('.'))
                .ToList();

            if (array.Count > 0)
            {
                cache.Keys.Where(p => array.Contains(Path.GetExtension(p))).ToList().ForEach(p => cache.Remove(p));
            }

            //排除非选择的平台
            array = Platform.Split('|', ',').ToList();
            if (array.Count > 1)
            {
                var deleteKey = new List <string>();
                foreach (var s in cache)
                {
                    foreach (var s1 in array.Skip(1).Where(p => !p.Equals(array.First())))
                    {
                        if (s.Key.ToLower().Contains(s1))
                        {
                            deleteKey.Add(s.Key);
                        }
                    }
                }
                foreach (var key in deleteKey)
                {
                    cache.Remove(key);
                }
            }

            OutUpdate(cache);
        }
Ejemplo n.º 4
0
        public bool ShouldSkip(string path)
        {
            if (!String.IsNullOrEmpty(Exclude))
            {
                if (Exclude.Split(new[] { ",", ";" }, StringSplitOptions.RemoveEmptyEntries)
                    .Any(s => path.Contains(s.Trim())))
                {
                    return(true);
                }
            }

            if (!String.IsNullOrEmpty(Include))
            {
                if (
                    Include.Split(new[] { ",", ";" }, StringSplitOptions.RemoveEmptyEntries)
                    .All(s => !path.Contains(s.Trim())))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        private Tuple <IEnumerable <SiteMapNode>, IEnumerable <SiteMapNode> > GetChildNodes()
        {
            var currentNode = SiteMap.CurrentNode;

            if (currentNode == null)
            {
                return(new Tuple <IEnumerable <SiteMapNode>, IEnumerable <SiteMapNode> >(new SiteMapNode[] {}, new SiteMapNode[] {}));
            }

            var excludeLogicalNames = string.IsNullOrEmpty(Exclude)
                                ? new HashSet <string>(StringComparer.InvariantCultureIgnoreCase)
                                : new HashSet <string>(Exclude.Split(',').Select(name => name.Trim()), StringComparer.InvariantCultureIgnoreCase);

            var shortcutNodes = new List <SiteMapNode>();
            var otherNodes    = new List <SiteMapNode>();

            foreach (SiteMapNode childNode in currentNode.ChildNodes)
            {
                var entityNode = childNode as CrmSiteMapNode;

                if (entityNode != null && excludeLogicalNames.Any(entityNode.HasCrmEntityName))
                {
                    continue;
                }

                if (entityNode != null && entityNode.HasCrmEntityName("adx_shortcut"))
                {
                    shortcutNodes.Add(childNode);

                    continue;
                }

                otherNodes.Add(childNode);
            }

            return(new Tuple <IEnumerable <SiteMapNode>, IEnumerable <SiteMapNode> >(otherNodes, shortcutNodes));
        }
Ejemplo n.º 6
0
        public override bool Execute()
        {
            WaitForDebuggerIfEnabled();

            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddTransient <IProcessExitHandler, ProcessExitHandler>();
            serviceCollection.AddTransient <IFileSystem, FileSystem>();
            serviceCollection.AddTransient <IConsole, SystemConsole>();
            serviceCollection.AddTransient <ILogger, MSBuildLogger>(_ => _logger);
            serviceCollection.AddTransient <IRetryHelper, RetryHelper>();
            // We cache resolutions
            serviceCollection.AddSingleton <ISourceRootTranslator, SourceRootTranslator>(serviceProvider => new SourceRootTranslator(Path, serviceProvider.GetRequiredService <ILogger>(), serviceProvider.GetRequiredService <IFileSystem>()));
            // We need to keep singleton/static semantics
            serviceCollection.AddSingleton <IInstrumentationHelper, InstrumentationHelper>();
            serviceCollection.AddSingleton <ICecilSymbolHelper, CecilSymbolHelper>();

            ServiceProvider = serviceCollection.BuildServiceProvider();

            try
            {
                var fileSystem = ServiceProvider.GetService <IFileSystem>();

                CoverageParameters parameters = new CoverageParameters
                {
                    IncludeFilters          = Include?.Split(','),
                    IncludeDirectories      = IncludeDirectory?.Split(','),
                    ExcludeFilters          = Exclude?.Split(','),
                    ExcludedSourceFiles     = ExcludeByFile?.Split(','),
                    ExcludeAttributes       = ExcludeByAttribute?.Split(','),
                    IncludeTestAssembly     = IncludeTestAssembly,
                    SingleHit               = SingleHit,
                    MergeWith               = MergeWith,
                    UseSourceLink           = UseSourceLink,
                    SkipAutoProps           = SkipAutoProps,
                    DoesNotReturnAttributes = DoesNotReturnAttribute?.Split(',')
                };

                Coverage coverage = new Coverage(Path,
                                                 parameters,
                                                 _logger,
                                                 ServiceProvider.GetService <IInstrumentationHelper>(),
                                                 ServiceProvider.GetService <IFileSystem>(),
                                                 ServiceProvider.GetService <ISourceRootTranslator>(),
                                                 ServiceProvider.GetService <ICecilSymbolHelper>());

                CoveragePrepareResult prepareResult = coverage.PrepareModules();
                InstrumenterState = new TaskItem(System.IO.Path.GetTempFileName());
                using (var instrumentedStateFile = fileSystem.NewFileStream(InstrumenterState.ItemSpec, FileMode.Open, FileAccess.Write))
                {
                    using (Stream serializedState = CoveragePrepareResult.Serialize(prepareResult))
                    {
                        serializedState.CopyTo(instrumentedStateFile);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        public override bool Execute()
        {
            Log.LogTaskName("GetDirectories");
            Log.LogTaskProperty("Path", Path);
            Log.LogTaskProperty("Pattern", Pattern);
            Log.LogTaskProperty("Option", Option);
            Log.LogTaskProperty("Exclude", Exclude);

            var path    = Path.Replace('\\', '/').TrimEnd('/');
            var exclude = new HashSet <string> ();
            var items   = new List <ITaskItem> ();
            IEnumerable <string> dirs;
            SearchOption         option;

            if (!string.IsNullOrEmpty(Option))
            {
                if (!Enum.TryParse(Option, out option))
                {
                    Log.LogError("Unknown search option: {0}", Option);
                    return(false);
                }
            }
            else
            {
                option = SearchOption.TopDirectoryOnly;
            }

            if (!Directory.Exists(path))
            {
                Directories = items.ToArray();

                return(!Log.HasLoggedErrors);
            }

            if (!string.IsNullOrEmpty(Pattern))
            {
                dirs = Directory.EnumerateDirectories(path, Pattern, option);
            }
            else
            {
                dirs = Directory.EnumerateDirectories(path, "*.*", option);
            }

            if (!string.IsNullOrEmpty(Exclude))
            {
                foreach (var rpath in Exclude.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    var full = System.IO.Path.Combine(path, rpath.Replace('\\', '/'));
                    exclude.Add(full);
                }
            }

            foreach (var dir in dirs)
            {
                if (!exclude.Contains(dir))
                {
                    items.Add(new TaskItem(dir));
                }
            }

            Directories = items.ToArray();

            return(!Log.HasLoggedErrors);
        }
Ejemplo n.º 8
0
 public PackageDependency AsReadOnly()
 {
     return(new PackageDependency(Id, VersionSpec, null, Exclude?.Split(',').Select(s => s.Trim()).ToList()));
 }