private static LineInfo YamlLineEnd(IXmlLineInfo node)
        {
            var content = node.ToString();

            if (node is XText)
            {
                var lines = LineSplitter.SplitLines(content);
                content = lines[0];
            }

            return(YamlLine(node.LineNumber, node.LinePosition - 1 + content.Length));
        }
        private static bool CreateYaml(string path, string allText, out Yaml.File yamlContent)
        {
            var lines = LineSplitter.SplitLines(allText);

            var file = YamlFile(lines, path);

            XDocument document = null;

            try
            {
                document = XDocument.Parse(allText, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
            }
            catch (Exception ex)
            {
                file.ParsingErrors.Add(new ParsingError {
                    ErrorMessage = ex.Message
                });
            }

            var parsingFine = file.ParsingErrors.Count == 0;

            if (parsingFine)
            {
                var root = YamlRoot(lines, allText);

                // adjust footer
                var footerStart = root.FooterSpan.End + 1;
                var footerEnd   = allText.Length - 1;
                if (footerStart < footerEnd)
                {
                    file.FooterSpan = new CharacterSpan(footerStart, footerEnd);
                }

                YamlInfrastructureCommentAndSchema(root, lines, allText);

                file.Children.Add(root);
                root.Children.AddRange(Yaml("resheader", document, lines));
                root.Children.AddRange(Yaml("data", document, lines));
                root.Children.AddRange(Yaml("metadata", document, lines));
                root.Children.AddRange(Yaml("assembly", document, lines));

                // sort based on span
                root.Children.Sort(new AscendingSpanComparer());
            }

            yamlContent = file;

            return(parsingFine);
        }