Ejemplo n.º 1
0
        public override bool Execute()
        {
            HashSet <string> processedFileNames = new HashSet <string>();
            AssemblyList     corerun            = new AssemblyList("Microsoft.NETCore.Runtime", "Microsoft.NETCore.TestHost", "Microsoft.NETCore.Windows.ApiSets");
            AssemblyList     xunit                    = new AssemblyList("xunit");
            List <string>    unmatched                = new List <string>();
            bool             foundDuplicates          = false;
            Stream           inputListLocationStream  = File.OpenRead(InputListLocation);
            Stream           outputListLocationStream = File.OpenWrite(OutputListLocation);

            using (StreamReader listReader = new StreamReader(inputListLocationStream))
            {
                string line;
                while ((line = listReader.ReadLine()) != null)
                {
                    var fileName = Path.GetFileName(line);
                    if (!processedFileNames.Add(fileName))
                    {
                        Log.LogError("Duplicate assembly found: {0}", fileName);
                        foundDuplicates = true;
                        continue;
                    }

                    if (corerun.TryAdd(line))
                    {
                        continue;
                    }

                    if (xunit.TryAdd(line))
                    {
                        continue;
                    }

                    unmatched.Add(line);
                }
            }

            if (foundDuplicates)
            {
                return(false);
            }

            Dictionary <string, List <string> > headers = new Dictionary <string, List <string> >
            {
                { "corerun", corerun.Dependencies },
                { "xunit", xunit.Dependencies },
                { "testdependency", unmatched },
            };

            using (StreamWriter listRewriter = new StreamWriter(outputListLocationStream))
                using (JsonWriter jsonWriter = new JsonTextWriter(listRewriter))
                {
                    jsonWriter.Formatting = Formatting.Indented;
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(jsonWriter, headers);
                }

            return(true);
        }
Ejemplo n.º 2
0
        public override bool Execute()
        {
            HashSet<string> processedFileNames = new HashSet<string>();
            AssemblyList corerun = new AssemblyList("Microsoft.NETCore.Runtime", "Microsoft.NETCore.TestHost", "Microsoft.NETCore.Windows.ApiSets");
            AssemblyList xunit = new AssemblyList("xunit");
            List<string> unmatched = new List<string>();
            bool foundDuplicates = false;
            Stream inputListLocationStream = File.OpenRead(InputListLocation);
            Stream outputListLocationStream = File.OpenWrite(OutputListLocation);

            using (StreamReader listReader = new StreamReader(inputListLocationStream))
            {
                string line;
                while ((line = listReader.ReadLine()) != null)
                {
                    var fileName = Path.GetFileName(line);
                    if (!processedFileNames.Add(fileName))
                    {
                        Log.LogError("Duplicate assembly found: {0}", fileName);
                        foundDuplicates = true;
                        continue;
                    }

                    if (corerun.TryAdd(line))
                    {
                        continue;
                    }

                    if (xunit.TryAdd(line))
                    {
                        continue;
                    }

                    unmatched.Add(line);
                }
            }

            if (foundDuplicates)
            {
                return false;
            }

            Dictionary<string, List<string>> headers = new Dictionary<string, List<string>>
            {
                {"corerun", corerun.Dependencies},
                {"xunit", xunit.Dependencies},
                {"testdependency", unmatched},
            };

            using (StreamWriter listRewriter = new StreamWriter(outputListLocationStream))
            using (JsonWriter jsonWriter = new JsonTextWriter(listRewriter))
            {
                jsonWriter.Formatting = Formatting.Indented;
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(jsonWriter, headers);
            }

            return true;
        }