コード例 #1
0
        public void TestBuildTreeStructureCount()
        {
            var binLog       = GetTestFile("1.binlog");
            var binaryLogger = new BinaryLogger();

            binaryLogger.Parameters = binLog;
            var buildSuccessful = MSBuild.BuildProjectFromFile(s_testProject, binaryLogger);

            Assert.True(buildSuccessful);

            var build = Serialization.Read(binLog);

            var projectEvaluations = build.FindChildrenRecursive <ProjectEvaluation>();

            Assert.Equal(3, projectEvaluations.Count);
            Assert.Equal(3, new HashSet <ProjectEvaluation>(projectEvaluations).Count);

            var projectInvocations = build.FindChildrenRecursive <Project>();

            Assert.Equal(5, projectInvocations.Count);
            Assert.Equal(5, new HashSet <Project>(projectInvocations).Count);

            Assert.Equal(7, build.FindChildrenRecursive <Target>().Count);

            Assert.Equal(10, build.FindChildrenRecursive <Task>().Count);

            Assert.Equal(4, build.FindChildrenRecursive <Item>().Count);
        }
コード例 #2
0
        public void TestBinaryLoggerRoundtrip(bool useInMemoryProject)
        {
            var binLog       = GetTestFile("1.binlog");
            var binaryLogger = new BinaryLogger();

            binaryLogger.Parameters = binLog;
            var buildSuccessful = useInMemoryProject
                ? MSBuild.BuildProjectInMemory(s_testProject, binaryLogger)
                : MSBuild.BuildProjectFromFile(s_testProject, binaryLogger);

            Assert.True(buildSuccessful);

            var build = Serialization.Read(binLog);
            var xml1  = GetTestFile("1.xml");
            var xml2  = GetTestFile("2.xml");

            Serialization.Write(build, xml1);

            Serialization.Write(build, GetTestFile("1.buildlog"));
            build = Serialization.Read(GetTestFile("1.buildlog"));

            Serialization.Write(build, xml2);

            Assert.False(Differ.AreDifferent(xml1, xml2));

            build = XlinqLogReader.ReadFromXml(xml1);
            Serialization.Write(build, GetTestFile("3.xml"));
            Assert.False(Differ.AreDifferent(xml1, GetTestFile("3.xml")));

            build = Serialization.Read(xml1);
            Serialization.Write(build, GetTestFile("4.xml"));

            Assert.False(Differ.AreDifferent(xml1, GetTestFile("4.xml")));
        }
コード例 #3
0
        public void TestBuildTreeStructureCount()
        {
            var binLog       = GetTestFile("1.binlog");
            var binaryLogger = new BinaryLogger();

            binaryLogger.Parameters = binLog;
            var buildSuccessful = MSBuild.BuildProjectFromFile(s_testProject, binaryLogger);

            Assert.True(buildSuccessful);

            var build = Serialization.Read(binLog);

            BuildAnalyzer.AnalyzeBuild(build);

            var projectEvaluations = build.FindChildrenRecursive <ProjectEvaluation>();

            Assert.Equal(3, projectEvaluations.Count);
            Assert.Equal(3, new HashSet <ProjectEvaluation>(projectEvaluations).Count);

            var projectInvocations = build.FindChildrenRecursive <Project>();

            Assert.Equal(5, projectInvocations.Count);
            Assert.Equal(5, new HashSet <Project>(projectInvocations).Count);

            Assert.Equal(7, build.FindChildrenRecursive <Target>().Count);

            Assert.Equal(10, build.FindChildrenRecursive <Task>().Count);

            var items = build.FindChildrenRecursive <Item>().ToArray();
            // This is flaky because sometimes items will be in the tree and sometimes not
            // so the result could be 4 or 8
            //Assert.Equal(4, items.Length);
        }