private object ReadNode()
        {
            var name   = reader.ReadString();
            var node   = Serialization.CreateNode(name);
            var folder = node as Folder;

            if (folder != null)
            {
                folder.Name = name;
            }

            reader.ReadStringArray(attributes);
            SetAttributes(node);
            int childrenCount = reader.ReadInt32();

            if (childrenCount > 0)
            {
                var treeNode = (TreeNode)node;
                for (int i = 0; i < childrenCount; i++)
                {
                    var child = ReadNode();
                    treeNode.AddChild(child);
                }
            }

            if (node is Build build && formatSupportsEmbeddedProjectImportsArchive)
            {
                build.SourceFilesArchive = reader.ReadByteArray();
            }

            return(node);
        }
Esempio n. 2
0
        private object ReadNode()
        {
            var name   = reader.ReadString();
            var node   = Serialization.CreateNode(name);
            var folder = node as Folder;

            if (folder != null)
            {
                folder.Name = name;
            }

            reader.ReadStringArray(attributes);
            SetAttributes(node);
            int childrenCount = reader.ReadInt32();

            if (childrenCount > 0)
            {
                var treeNode = (TreeNode)node;
                for (int i = 0; i < childrenCount; i++)
                {
                    var child = ReadNode();
                    treeNode.AddChild(child);
                }
            }

            return(node);
        }
Esempio n. 3
0
        private object ReadNode()
        {
            var name   = reader.ReadString();
            var node   = Serialization.CreateNode(name);
            var folder = node as Folder;

            if (folder != null)
            {
                folder.Name = name;
            }

            reader.ReadStringArray(attributes);
            SetAttributes(node);
            int childrenCount = reader.ReadInt32();

            if (childrenCount > 0)
            {
                if (!(node is TreeNode))
                {
                    // OK we got ourselves into a situation here.
                    // https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/242
                    // There's a design flaw in the BuildLog format. I took a shortcut
                    // and for Folder nodes I just write the name of the folder instead
                    // of specifying that the element is a Folder in the first place.
                    // Unfortunately I didn't think about Folders named "Property",
                    // "Target", etc.
                    // So the deserialization logic when it sees a string called "Property"
                    // it assumes we have a property here, instead of a Folder named
                    // "Property". But properties have children! We're in a pickle now.
                    // Longer term I need to modify the format to not do this optimization
                    // and always write "Folder" for folders and write the name separately.
                    // For now I don't have time to do this right, so put in the dirty
                    // hack to recover from this situation. If it says it's a "Property"
                    // but expects children, it means it's actually a folder with name
                    // "Property".
                    folder      = new Folder();
                    folder.Name = Serialization.GetNodeName(node);
                    node        = folder;
                }

                var treeNode = (TreeNode)node;
                for (int i = 0; i < childrenCount; i++)
                {
                    var child = ReadNode();
                    treeNode.AddChild(child);
                }
            }

            if (node is Build build && formatSupportsEmbeddedProjectImportsArchive)
            {
                build.SourceFilesArchive = reader.ReadByteArray();
            }

            return(node);
        }
Esempio n. 4
0
        private BaseNode ReadNode(XElement element)
        {
            var name = element.Name.LocalName;

            if (name == "Metadata")
            {
                var metadata = new Metadata()
                {
                    Name  = GetString(element, AttributeNames.Name),
                    Value = ReadTextContent(element)
                };

                return(metadata);
            }
            else if (name == "Property")
            {
                var property = new Property()
                {
                    Name  = GetString(element, AttributeNames.Name),
                    Value = ReadTextContent(element)
                };

                return(property);
            }

            var node = Serialization.CreateNode(name);

            var folder = node as Folder;

            if (folder != null)
            {
                folder.Name = name;
            }

            var build = node as Build;

            if (build != null)
            {
                this.stringTable = build.StringTable;
            }

            ReadAttributes(node, element);

            if (element.HasElements)
            {
                var treeNode = (TreeNode)node;
                foreach (var childElement in element.Elements())
                {
                    var childNode = ReadNode(childElement);
                    treeNode.AddChild(childNode);
                }
            }

            return(node);
        }
        private object ReadNode()
        {
            var name = stringTable.Intern(reader.Name);

            ReadAttributes();

            // shortcut for most common types (Metadata and Property)
            if (name == "Metadata")
            {
                var metadata = new Metadata()
                {
                    Name = GetString(AttributeNames.Name)
                };

                return(metadata);
            }
            else if (name == "Property")
            {
                var property = new Property()
                {
                    Name = GetString(AttributeNames.Name)
                };

                return(property);
            }

            object node = Serialization.CreateNode(name);

            var folder = node as Folder;

            if (folder != null)
            {
                folder.Name           = GetString(AttributeNames.Name) ?? name;
                folder.IsLowRelevance = GetBoolean(AttributeNames.IsLowRelevance);
                return(folder);
            }

            PopulateAttributes(node);

            return(node);
        }