XmlElementSyntax

We found 10 examples in language CSharp for this search. You will see 46 fragments of code.

        public static XmlElementSyntax MultiLineElement(string localName, string newLineText, SyntaxList<XmlNodeSyntax> content)
        {
            return MultiLineElement(SyntaxFactory.XmlName(localName), newLineText, content);
        }

        public static XmlElementSyntax Element(string localName, SyntaxList<XmlNodeSyntax> content)
        {
            return Element(SyntaxFactory.XmlName(localName), content);
        }

        public static XmlElementSyntax Element(XmlNameSyntax name, SyntaxList<XmlNodeSyntax> content)
        {
            return SyntaxFactory.XmlElement(
                SyntaxFactory.XmlElementStartTag(name),
                content,
                SyntaxFactory.XmlElementEndTag(name));
        }

        public static XmlElementSyntax SummaryElement(string newLineText, params XmlNodeSyntax[] content)
        {
            return SummaryElement(newLineText, List(content));
        }

        public static XmlElementSyntax SummaryElement(string newLineText, SyntaxList<XmlNodeSyntax> content)
        {
            return MultiLineElement(XmlCommentHelper.SummaryXmlTag, newLineText, content);
        }

        public static XmlElementSyntax RemarksElement(string newLineText, params XmlNodeSyntax[] content)
        {
            return RemarksElement(newLineText, List(content));
        }


        public static XmlElementSyntax GetXmlCommentParam(this DocumentationCommentTriviaSyntax documentationSyntax, string xmlParamName) =>
            documentationSyntax?.ChildNodes()
                                .OfType<XmlElementSyntax>()
                                .FirstOrDefault(xmlElementSyntax => xmlElementSyntax.IsXmlCommentParam(xmlParamName));

        public static bool IsXmlCommentParam(this XmlElementSyntax xmlElement, string xmlParamName) =>
            xmlElement.StartTag.Name.LocalName.Text == "param" &&
            xmlElement.StartTag.Attributes.Any(attribute => attribute is XmlNameAttributeSyntax nameAttribute &&
                                                            nameAttribute.Identifier.Identifier.Text == xmlParamName);

        private static XmlTextSyntax GetSimpleCommentText(this XmlElementSyntax xmlCommentParam) =>
            xmlCommentParam.Content.Count != 1 ? null : xmlCommentParam.Content[0] as XmlTextSyntax;

    #region Public Methods and Operators

    /// <summary>Checks whether a documentation header exists for the given syntax node.</summary>
    /// <param name="syntaxNode">The syntax node to check.</param>
    /// <returns>True if a documentation header exists for the given <paramref name="syntaxNode" />.</returns>
    /// <exception cref="ArgumentNullException">Occurs if <paramref name="syntaxNode" /> is null.</exception>
    public static bool HasDocumentationHeader(SyntaxNode syntaxNode)
    {
      IEnumerable<DocumentationCommentTriviaSyntax> docTrivia;

      if (syntaxNode == null)
      {
        throw new ArgumentNullException(nameof(syntaxNode));
      }

      docTrivia = GetDocumentationTrivia(syntaxNode);

      return docTrivia.Any();
    }

    /// <summary>Gets the position of a declarations first empty documentation tag.</summary>
    /// <param name="declaration">The declaration.</param>
    /// <returns>The position of the declarations first empty documentation tag.
    /// A value less than zero (0) will be returned, if no empty documentation tag exists.</returns>
    public static int GetPositionOfFirstEmptyDocumentationTag(MemberDeclarationSyntax declaration)
    {
      IEnumerable<XmlElementSyntax> docTrivia;
      IEnumerable<XmlElementSyntax> emptyTrivia;
      XmlElementSyntax firstEmptyTrivia;
      int result = -1;

      docTrivia = DocumentationHelper.GetDocumentationTrivia(declaration).SelectMany(t => t.Content.OfType<XmlElementSyntax>());
      emptyTrivia = docTrivia.Where(t => !t.ChildNodes().OfType<XmlTextSyntax>().Any());
      firstEmptyTrivia = emptyTrivia.FirstOrDefault();

      if (firstEmptyTrivia != null)
      {
        result = firstEmptyTrivia.EndTag.SpanStart;
      }

      return result;
    }

    #endregion

    #region Methods

    /// <summary>Gets the documentation trivia of a syntax node.</summary>
    /// <param name="syntaxNode">The syntax node to get the documentation trivia for.</param>
    /// <returns>The documentation trivia of the <paramref name="syntaxNode" />.</returns>
    private static IEnumerable<DocumentationCommentTriviaSyntax> GetDocumentationTrivia(SyntaxNode syntaxNode)
    {
      IEnumerable<DocumentationCommentTriviaSyntax> docTrivia;
      SyntaxTriviaList leadingTrivia;

      leadingTrivia = syntaxNode.GetLeadingTrivia();
      docTrivia = leadingTrivia
        .Select(t => t.GetStructure())
        .OfType<DocumentationCommentTriviaSyntax>();

      return docTrivia;
    }


		/// <summary>
		/// Creates only summary documentation comment trivia.
		/// </summary>
		/// <param name="content">The content.</param>
		/// <returns>A DocumentationCommentTriviaSyntax.</returns>
		public static DocumentationCommentTriviaSyntax CreateOnlySummaryDocumentationCommentTrivia(string content)
		{
			SyntaxList<XmlNodeSyntax> list = SyntaxFactory.List(CreateSummaryPartNodes(content));
			return SyntaxFactory.DocumentationCommentTrivia(SyntaxKind.SingleLineDocumentationCommentTrivia, list);
		}

		/// <summary>
		/// Creates summary part nodes.
		/// </summary>
		/// <param name="content">The content.</param>
		/// <returns>An array of XmlNodeSyntaxes.</returns>
		public static XmlNodeSyntax[] CreateSummaryPartNodes(string content)
		{
			/*
                 ///[0] <summary>
                 /// The code fix provider.
                 /// </summary>[1] [2]
             */

			// [0] " " + leading comment exterior trivia
			XmlTextSyntax xmlText0 = CreateLineStartTextSyntax();

			// [1] Summary
			XmlElementSyntax xmlElement = CreateSummaryElementSyntax(content);

			// [2] new line 
			XmlTextSyntax xmlText1 = CreateLineEndTextSyntax();

			return new XmlNodeSyntax[] { xmlText0, xmlElement, xmlText1 };

		}

		/// <summary>
		/// Creates parameter part nodes.
		/// </summary>
		/// <param name="parameterName">The parameter name.</param>
		/// <param name="parameterContent">The parameter content.</param>
		/// <returns>An array of XmlNodeSyntaxes.</returns>
		public static XmlNodeSyntax[] CreateParameterPartNodes(string parameterName, string parameterContent)
		{
			///[0] <param name="parameterName"></param>[1][2]

			// [0] -- line start text 
			XmlTextSyntax lineStartText = CreateLineStartTextSyntax();

			// [1] -- parameter text
			XmlElementSyntax parameterText = CreateParameterElementSyntax(parameterName, parameterContent);

			// [2] -- line end text 
			XmlTextSyntax lineEndText = CreateLineEndTextSyntax();

			return new XmlNodeSyntax[] { lineStartText, parameterText, lineEndText };
		}

		/// <summary>
		/// Creates return part nodes.
		/// </summary>
		/// <param name="content">The content.</param>
		/// <returns>An array of XmlNodeSyntaxes.</returns>
		public static XmlNodeSyntax[] CreateReturnPartNodes(string content)
		{
			///[0] <returns></returns>[1][2]

			XmlTextSyntax lineStartText = CreateLineStartTextSyntax();

			XmlElementSyntax returnElement = CreateReturnElementSyntax(content);

			XmlTextSyntax lineEndText = CreateLineEndTextSyntax();

			return new XmlNodeSyntax[] { lineStartText, returnElement, lineEndText };
		}

		/// <summary>
		/// Creates summary element syntax.
		/// </summary>
		/// <param name="content">The content.</param>
		/// <returns>A XmlElementSyntax.</returns>
		private static XmlElementSyntax CreateSummaryElementSyntax(string content)
		{
			XmlNameSyntax xmlName = SyntaxFactory.XmlName(SyntaxFactory.Identifier(DocumentationHeaderHelper.Summary));
			XmlElementStartTagSyntax summaryStartTag = SyntaxFactory.XmlElementStartTag(xmlName);
			XmlElementEndTagSyntax summaryEndTag = SyntaxFactory.XmlElementEndTag(xmlName);

			return SyntaxFactory.XmlElement(
				summaryStartTag,
				SyntaxFactory.SingletonList<XmlNodeSyntax>(CreateSummaryTextSyntax(content)),
				summaryEndTag);
		}

		/// <summary>
		/// Creates parameter element syntax.
		/// </summary>
		/// <param name="parameterName">The parameter name.</param>
		/// <param name="parameterContent">The parameter content.</param>
		/// <returns>A XmlElementSyntax.</returns>
		private static XmlElementSyntax CreateParameterElementSyntax(string parameterName, string parameterContent)
		{
			XmlNameSyntax paramName = SyntaxFactory.XmlName("param");

			/// <param name="parameterName">[0][1]</param>[2]

			// [0] -- param start tag with attribute
			XmlNameAttributeSyntax paramAttribute = SyntaxFactory.XmlNameAttribute(parameterName);
			XmlElementStartTagSyntax startTag = SyntaxFactory.XmlElementStartTag(paramName, SyntaxFactory.SingletonList<XmlAttributeSyntax>(paramAttribute));

			// [1] -- content
			XmlTextSyntax content = SyntaxFactory.XmlText(parameterContent);

			// [2] -- end tag
			XmlElementEndTagSyntax endTag = SyntaxFactory.XmlElementEndTag(paramName);
			return SyntaxFactory.XmlElement(startTag, SyntaxFactory.SingletonList<SyntaxNode>(content), endTag);
		}

        public abstract SyntaxNode FixParameters(MethodDeclarationSyntax method, SyntaxNode root);

        protected async Task<Document> FixParametersAsync(Document document, Diagnostic diagnostic, CancellationToken c)
        {
            var root = await document.GetSyntaxRootAsync(c).ConfigureAwait(false);
            var documentationNode = root.FindToken(diagnostic.Location.SourceSpan.Start).Parent.AncestorsAndSelf().OfType<MethodDeclarationSyntax>().First();
            var newRoot = FixParameters(documentationNode, root);
            var newDocument = document.WithSyntaxRoot(newRoot);
            return newDocument;
        }

        protected static IEnumerable<Tuple<ParameterSyntax, Tuple<XmlElementSyntax, XmlNameAttributeSyntax>>> GetMethodParametersWithDocParameters(MethodDeclarationSyntax method, DocumentationCommentTriviaSyntax documentationNode)
        {
            var methodParameters = method.ParameterList.Parameters;

            var xElementsWitAttrs = documentationNode.Content.OfType<XmlElementSyntax>()
                                    .Where(xEle => xEle.StartTag.Name.LocalName.ValueText == "param")
                                    .SelectMany(xEle => xEle.StartTag.Attributes, (xEle, attr) => new Tuple<XmlElementSyntax, XmlNameAttributeSyntax>(xEle, (XmlNameAttributeSyntax)attr));

            var keys = methodParameters.Select(parameter => parameter.Identifier.ValueText)
                .Union(xElementsWitAttrs.Select(x => x.Item2.Identifier.Identifier.ValueText))
                .ToImmutableList();

            return (from key in keys
                    let Parameter = methodParameters.FirstOrDefault(p => p.Identifier.ValueText == key)
                    let DocParameter = xElementsWitAttrs.FirstOrDefault(p => p.Item2.Identifier.Identifier.ValueText == key)
                    select new Tuple<ParameterSyntax, Tuple<XmlElementSyntax, XmlNameAttributeSyntax>>(Parameter, DocParameter));
        }

        /// <summary>
        /// Responsible for parsing the passed in nuspec xml document. This will then result in a
        /// parsed package from that xml.
        /// </summary>
        /// <param name="document">The nuspec xml document to parse.</param>
        /// <returns>The full chocolatey package that was parsed from the specified xml document.</returns>
        public static Package ParseXmlDocument(XmlDocumentSyntax document)
        {
            var package = new Package();
            var allElements = new SortedDictionary<string, MetaValue<string>>();

            foreach (var element in document.DescendantNodes().OfType<XmlElementSyntax>())
            {
                switch (element.Name.ToLowerInvariant())
                {
                    case "owners":
                        package.Maintainers = ReadDelimitedList(element, ',');
                        break;

                    case "authors":
                        package.Authors = ReadDelimitedList(element, ',');
                        break;

                    case "tags":
                        package.Tags = ReadDelimitedList(element, ' ');
                        break;

                    case "metadata":
                        package.StartsAt = element.Start;
                        package.EndsAt = element.StartTag.End;
                        break;

                    case "dependencies":
                        var descendants = element.DescendantNodes().OfType<XmlEmptyElementSyntax>();
                        AddDependencies(descendants, package);
                        break;

                    case "package":
                    case "files":
                        break;

                    default:
                        SetObjectProperty(package, element);
                        break;
                }

                AppendElementToDictionary (allElements, element);
            }

            package.AllElements = allElements;

            return package;
        }

        private static void AddDependencies(IEnumerable<XmlEmptyElementSyntax> dependencyElements, Package package)
        {
            foreach (var element in dependencyElements)
            {
                if (string.Compare(element.Name, "dependency", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    var dependency = ParseDependency(element);
                    if (!string.IsNullOrEmpty(dependency.Value.Id))
                    {
                        package.AddDependency(ParseDependency(element));
                    }
                }
            }
        }

        private static void AppendElementToDictionary(SortedDictionary<string, MetaValue<string>> allElements, XmlElementSyntax element)
        {
            if (!element.Elements.Any())
            {
                var metaValue = new MetaValue<string>(element.GetContentValue())
                {
                    ElementEnd = element.End,
                    ElementStart = element.Start,
                    TextEnd = element.EndTag.Start,
                    TextStart = element.StartTag.End,
                    IsMissing = false
                };
                allElements.Add(element.Name, metaValue);
            }
        }

        private static MetaValue<Dependency> ParseDependency(XmlEmptyElementSyntax element)
        {
            var dependency = new Dependency();

            SetAttributeMetaValue(dependency.Id, element, "id");
            SetAttributeMetaValue(dependency.VersionRange, element, "version");

            return new MetaValue<Dependency>(dependency)
            {
                IsMissing = false,
                ElementStart = element.Start,
                ElementEnd = element.End
            };
        }

        private static IReadOnlyList<MetaValue<string>> ReadDelimitedList(XmlElementSyntax text, char delimiter)
        {
            var contentValue = text.GetContentValue();
            if (string.IsNullOrWhiteSpace(contentValue)) { return new MetaValue<string>[0]; }

            var values = contentValue.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
            var listResult = new List<MetaValue<string>>();

            foreach (var value in values)
            {
                int start = text.StartTag.End + contentValue.IndexOf(value);
                int end = start + value.Length;
                listResult.Add(new MetaValue<string>
                {
                    ElementEnd = text.Start,
                    ElementStart = text.End,
                    TextEnd = end,
                    TextStart = start,
                    Value = value,
                    IsMissing = false
                });
            }

            return listResult.AsReadOnly();
        }

        private static void SetAttributeMetaValue(MetaValue<string> metaValue, XmlEmptyElementSyntax element, string attributeName)
        {
            var attribute = element.GetAttribute(attributeName);
            if (attribute != null)
            {
                metaValue.Value = attribute.Value;
                metaValue.ElementStart = attribute.Start;
                metaValue.ElementEnd = attribute.End;
                metaValue.TextStart = attribute.ValueNode.Start;
                metaValue.TextEnd = attribute.ValueNode.End;
                metaValue.IsMissing = false;
            }
            else
            {
                metaValue.ElementStart = element.Start;
                metaValue.ElementEnd = element.End;
            }
        }

        /// <summary>
        /// Xmls the new line token using the specified indentation trivia
        /// </summary>
        /// <param name="indentationTrivia">The indentation trivia</param>
        /// <returns>The syntax token</returns>
        public static SyntaxToken XmlNewLineToken(SyntaxTrivia indentationTrivia) => SyntaxFactory
            .XmlTextNewLine(Environment.NewLine, false)
            .WithTrailingTrivia(SyntaxFactory.TriviaList(indentationTrivia, SyntaxFactory
                .DocumentationCommentExterior("/// ")));

        /// <summary>
        /// Summaries the summary lines
        /// </summary>
        /// <param name="summaryLines">The summary lines</param>
        /// <param name="xmlIndentedNewLine">The xml indented new line</param>
        /// <param name="keepSameLine">The keep same line</param>
        /// <returns>The xml element syntax</returns>
        public static XmlElementSyntax Summary(IEnumerable<string> summaryLines, SyntaxToken xmlIndentedNewLine,
            bool keepSameLine)
        {
            var xmlSummaryLines = new List<XmlNodeSyntax>();

            xmlSummaryLines.Add(SyntaxFactory
                .XmlText(SyntaxFactory.TokenList(xmlIndentedNewLine)));

            foreach (var summaryLine in summaryLines)
            {
                if (summaryLine.Contains("<<") && summaryLine.Contains(">>"))
                {
                    // Get class name
                    var className = summaryLine.SubstringBetween("<<", ">>");

                    if (!string.IsNullOrWhiteSpace(className))
                    {
                        var beforeToken = summaryLine.Split("<<").FirstOrDefault() ?? string.Empty;
                        var afterToken = summaryLine.Split(">>").LastOrDefault() ?? string.Empty;

                        var seeElement = See(className);

                        var beforeSeeElement = SyntaxFactory
                            .XmlText(SyntaxFactory.TokenList(SyntaxFactory.XmlTextLiteral(beforeToken)));

                        var afterSeeElement = SyntaxFactory
                            .XmlText(SyntaxFactory.TokenList(SyntaxFactory.XmlTextLiteral(afterToken)));

                        xmlSummaryLines.Add(beforeSeeElement);
                        xmlSummaryLines.Add(seeElement);
                        xmlSummaryLines.Add(afterSeeElement);
                    }
                }
                else
                {
                    xmlSummaryLines.Add(SyntaxFactory
                        .XmlText(SyntaxFactory.TokenList(SyntaxFactory.XmlTextLiteral(summaryLine))));
                }

                xmlSummaryLines.Add(SyntaxFactory
                    .XmlText(SyntaxFactory.TokenList(xmlIndentedNewLine)));
            }

            // Declare the summary XML element
            return SyntaxFactory.XmlSummaryElement(xmlSummaryLines.ToArray());
        }

        /// <summary>
        /// Returnses the description
        /// </summary>
        /// <param name="description">The description</param>
        /// <returns>The xml element syntax</returns>
        public static XmlElementSyntax Returns(string description) => SyntaxFactory
            .XmlReturnsElement(SyntaxFactory
                .XmlText(description));

        /// <summary>
        /// Exceptions the exception
        /// </summary>
        /// <param name="exception">The exception</param>
        /// <param name="description">The description</param>
        /// <returns>The xml element syntax</returns>
        public static XmlElementSyntax Exception(string exception, string description) => SyntaxFactory
            .XmlExceptionElement(SyntaxFactory
                .TypeCref(SyntaxFactory.ParseTypeName(exception)), SyntaxFactory
                .XmlText(description));

        /// <summary>
        /// Sees the type
        /// </summary>
        /// <param name="type">The type</param>
        /// <returns>The xml empty element syntax</returns>
        public static XmlEmptyElementSyntax See(string type) => SyntaxFactory
            .XmlSeeElement(SyntaxFactory
                .TypeCref(SyntaxFactory
                    .ParseTypeName(type)));

        /// <summary>
        /// Sees the also using the specified type
        /// </summary>
        /// <param name="type">The type</param>
        /// <returns>The xml empty element syntax</returns>
        public static XmlEmptyElementSyntax SeeAlso(string type) => SyntaxFactory
            .XmlSeeAlsoElement(SyntaxFactory
                .TypeCref(SyntaxFactory
                    .ParseTypeName(type)));

using Microsoft.Language.Xml;
using System;
using System.Collections.Generic;
using System.Linq;

namespace MSBuildProjectTools.LanguageServer.SemanticModel
{
    /// <summary>
    ///     Represents an XML element with content.
    /// </summary>
    public class XSElementWithContent
        : XSElement
    {
        /// <summary>
        ///     The range, within the source text, spanned by the node.
        /// </summary>
        /// <param name="element">
        ///     The <see cref="XmlElementSyntax"/> represented by the <see cref="XSElementWithContent"/>.
        /// </param>
        /// <param name="range">
        ///     The <see cref="Range"/>, within the source text, spanned by the element and its content.
        /// </param>
        /// <param name="nameRange">
        ///     The range, within the source text, spanned by the element's name.
        /// </param>
        /// <param name="openingTagRange">
        ///     The <see cref="Range"/>, within the source text, spanned by the element's opening tag.
        /// </param>
        /// <param name="attributesRange">
        ///     The range, within the source text, spanned by the element's attributes.
        /// </param>
        /// <param name="contentRange">
        ///     The <see cref="Range"/>, within the source text, spanned by the element's content.
        /// </param>
        /// <param name="closingTagRange">
        ///     The <see cref="Range"/>, within the source text, spanned by the element's closing tag.
        /// </param>
        /// <param name="parent">
        ///     The <see cref="XSElementWithContent"/>'s parent element (if any).
        /// </param>
        public XSElementWithContent(XmlElementSyntax element, Range range, Range nameRange, Range openingTagRange, Range attributesRange, Range contentRange, Range closingTagRange, XSElement parent)
            : base(element, range, nameRange, attributesRange, parent)
        {
            OpeningTagRange = openingTagRange;
            ContentRange = contentRange;
            ClosingTagRange = closingTagRange;
        }

        /// <summary>
        ///     The <see cref="XmlElementSyntax"/> represented by the <see cref="XSElementWithContent"/>.
        /// </summary>
        public new XmlElementSyntax ElementNode => (XmlElementSyntax)SyntaxNode;

        /// <summary>
        ///     The <see cref="Range"/>, within the source text, spanned by the element's opening tag.
        /// </summary>
        public Range OpeningTagRange { get; }

        /// <summary>
        ///     The <see cref="Range"/>, within the source text, spanned by the element's content.
        /// </summary>
        public Range ContentRange { get; }

        /// <summary>
        ///     The <see cref="Range"/>, within the source text, spanned by the element's closing tag.
        /// </summary>
        public Range ClosingTagRange { get; }

        /// <summary>
        ///     The kind of XML node represented by the <see cref="XSNode"/>.
        /// </summary>
        public override XSNodeKind Kind => XSNodeKind.Element;

        /// <summary>
        ///     Does the <see cref="XSNode"/> represent valid XML?
        /// </summary>
        public override bool IsValid => true;

        /// <summary>
        ///     Does the <see cref="XSElement"/> have any content (besides attributes)?
        /// </summary>
        public override bool HasContent => Content.Count > 0;
    }
}


        public override SyntaxNode FixParameters(MethodDeclarationSyntax method, SyntaxNode root)
        {
            var documentationNode = method.GetLeadingTrivia().Select(x => x.GetStructure()).OfType<DocumentationCommentTriviaSyntax>().First();
            var newDocumentationNode = documentationNode;
            var methodParameterWithDocParameter = GetMethodParametersWithDocParameters(method, documentationNode);

            var newFormation = newDocumentationNode.Content.OfType<XmlElementSyntax>();

            var nodesToAdd = methodParameterWithDocParameter.Where(p => p.Item2 == null)
                                .Select(x => CreateParamenterXmlDocumentation(x.Item1.Identifier.ValueText, method.Identifier.ValueText))
                                .Union(newFormation)
                                .OrderByDescending(xEle => xEle.StartTag.Name.LocalName.ValueText == "summary")
                                .ThenByDescending(xEle => xEle.StartTag.Name.LocalName.ValueText == "param")
                                .SelectMany(EnvolveXmlDocSyntaxWithNewLine)
                                .ToList();

            newDocumentationNode = newDocumentationNode.WithContent(SyntaxFactory.List(nodesToAdd));

            return root.ReplaceNode(documentationNode, newDocumentationNode);
        }

        private static XmlElementSyntax CreateParamenterXmlDocumentation(string paramenterName, string methodName)
        {
            var content = $"todo: describe {paramenterName} parameter on {methodName}";
            var xmlTagName = SyntaxFactory.XmlName(SyntaxFactory.Identifier(@"param "));
            var startTag = SyntaxFactory.XmlElementStartTag(xmlTagName).WithAttributes(CreateXmlAttributes(paramenterName));
            var endTag = SyntaxFactory.XmlElementEndTag(SyntaxFactory.XmlName(SyntaxFactory.Identifier(@"param")));

            var xmlElementSyntax = SyntaxFactory.XmlElement(startTag, endTag).WithContent(CreateXmlElementContent(content));

            return xmlElementSyntax;
        }

        private static XmlNodeSyntax[] EnvolveXmlDocSyntaxWithNewLine(XmlElementSyntax xmlElementSyntax)
        {
            var emptyTriviaList = SyntaxFactory.TriviaList();

            var syntaxTriviaList = SyntaxFactory.TriviaList(SyntaxFactory.DocumentationCommentExterior(@"///"));
            var xmlTextLiteral = SyntaxFactory.XmlTextNewLine(syntaxTriviaList, WHITESPACE, WHITESPACE, emptyTriviaList);
            var withTextTokens = SyntaxFactory.XmlText(SyntaxFactory.TokenList(xmlTextLiteral));

            var xmlNewTextLiteral = SyntaxFactory.XmlTextNewLine(emptyTriviaList, string.Empty, string.Empty, SyntaxFactory.TriviaList(SyntaxFactory.ElasticCarriageReturnLineFeed));
            var withNewLineTokens = SyntaxFactory.XmlText(SyntaxFactory.TokenList(xmlNewTextLiteral));

            return new XmlNodeSyntax[] { withTextTokens, xmlElementSyntax, withNewLineTokens };
        }

        private static SyntaxList<XmlNodeSyntax> CreateXmlElementContent(string content)
        {
            var triviaList = SyntaxFactory.TriviaList();
            var xmlTextLiteral = SyntaxFactory.XmlTextLiteral(triviaList, content, content, triviaList);
            return SyntaxFactory.SingletonList<XmlNodeSyntax>(SyntaxFactory.XmlText(SyntaxFactory.TokenList(xmlTextLiteral)));
        }

        private static SyntaxList<XmlAttributeSyntax> CreateXmlAttributes(string paramenterName)
        {
            var xmlNameSyntax = SyntaxFactory.XmlName(SyntaxFactory.Identifier("name"));
            var quoteToken = SyntaxFactory.Token(DoubleQuoteToken);
            var identifierNameSyntax = SyntaxFactory.IdentifierName(paramenterName.Trim());
            var equalsToken = SyntaxFactory.Token(EqualsToken);
            var xmlNameAttributeSyntax = SyntaxFactory.XmlNameAttribute(xmlNameSyntax, equalsToken, quoteToken, identifierNameSyntax, quoteToken);
            return SyntaxFactory.SingletonList<XmlAttributeSyntax>(xmlNameAttributeSyntax);
        }

        public override sealed Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            var diagnostic = context.Diagnostics.First();
            context.RegisterCodeFix(CodeAction.Create(Resources.XmlDocumentationCreateMissingParametersCodeFixProvider_Title, c => FixParametersAsync(context.Document, diagnostic, c)), diagnostic);
            return Task.FromResult(0);
        }


		/// <summary>
		/// Creates only summary documentation comment trivia.
		/// </summary>
		/// <param name="content">The content.</param>
		/// <returns>A DocumentationCommentTriviaSyntax.</returns>
		public static DocumentationCommentTriviaSyntax CreateOnlySummaryDocumentationCommentTrivia(string content)
		{
			SyntaxList<XmlNodeSyntax> list = SyntaxFactory.List(CreateSummaryPartNodes(content));
			return SyntaxFactory.DocumentationCommentTrivia(SyntaxKind.SingleLineDocumentationCommentTrivia, list);
		}

		/// <summary>
		/// Creates summary part nodes.
		/// </summary>
		/// <param name="content">The content.</param>
		/// <returns>An array of XmlNodeSyntaxes.</returns>
		public static XmlNodeSyntax[] CreateSummaryPartNodes(string content)
		{
			/*
                 ///[0] <summary>
                 /// The code fix provider.
                 /// </summary>[1] [2]
             */

			// [0] " " + leading comment exterior trivia
			XmlTextSyntax xmlText0 = CreateLineStartTextSyntax();

			// [1] Summary
			XmlElementSyntax xmlElement = CreateSummaryElementSyntax(content);

			// [2] new line 
			XmlTextSyntax xmlText1 = CreateLineEndTextSyntax();

			return new XmlNodeSyntax[] { xmlText0, xmlElement, xmlText1 };

		}

		/// <summary>
		/// Creates parameter part nodes.
		/// </summary>
		/// <param name="parameterName">The parameter name.</param>
		/// <param name="parameterContent">The parameter content.</param>
		/// <returns>An array of XmlNodeSyntaxes.</returns>
		public static XmlNodeSyntax[] CreateParameterPartNodes(string parameterName, string parameterContent)
		{
			///[0] <param name="parameterName"></param>[1][2]

			// [0] -- line start text 
			XmlTextSyntax lineStartText = CreateLineStartTextSyntax();

			// [1] -- parameter text
			XmlElementSyntax parameterText = CreateParameterElementSyntax(parameterName, parameterContent);

			// [2] -- line end text 
			XmlTextSyntax lineEndText = CreateLineEndTextSyntax();

			return new XmlNodeSyntax[] { lineStartText, parameterText, lineEndText };
		}

		/// <summary>
		/// Creates return part nodes.
		/// </summary>
		/// <param name="content">The content.</param>
		/// <returns>An array of XmlNodeSyntaxes.</returns>
		public static XmlNodeSyntax[] CreateReturnPartNodes(string content)
		{
			///[0] <returns></returns>[1][2]

			XmlTextSyntax lineStartText = CreateLineStartTextSyntax();

			XmlElementSyntax returnElement = CreateReturnElementSyntax(content);

			XmlTextSyntax lineEndText = CreateLineEndTextSyntax();

			return new XmlNodeSyntax[] { lineStartText, returnElement, lineEndText };
		}

		/// <summary>
		/// Creates summary element syntax.
		/// </summary>
		/// <param name="content">The content.</param>
		/// <returns>A XmlElementSyntax.</returns>
		private static XmlElementSyntax CreateSummaryElementSyntax(string content)
		{
			XmlNameSyntax xmlName = SyntaxFactory.XmlName(SyntaxFactory.Identifier(DocumentationHeaderHelper.Summary));
			XmlElementStartTagSyntax summaryStartTag = SyntaxFactory.XmlElementStartTag(xmlName);
			XmlElementEndTagSyntax summaryEndTag = SyntaxFactory.XmlElementEndTag(xmlName);

			return SyntaxFactory.XmlElement(
				summaryStartTag,
				SyntaxFactory.SingletonList<XmlNodeSyntax>(CreateSummaryTextSyntax(content)),
				summaryEndTag);
		}

		/// <summary>
		/// Creates parameter element syntax.
		/// </summary>
		/// <param name="parameterName">The parameter name.</param>
		/// <param name="parameterContent">The parameter content.</param>
		/// <returns>A XmlElementSyntax.</returns>
		private static XmlElementSyntax CreateParameterElementSyntax(string parameterName, string parameterContent)
		{
			XmlNameSyntax paramName = SyntaxFactory.XmlName("param");

			/// <param name="parameterName">[0][1]</param>[2]

			// [0] -- param start tag with attribute
			XmlNameAttributeSyntax paramAttribute = SyntaxFactory.XmlNameAttribute(parameterName);
			XmlElementStartTagSyntax startTag = SyntaxFactory.XmlElementStartTag(paramName, SyntaxFactory.SingletonList<XmlAttributeSyntax>(paramAttribute));

			// [1] -- content
			XmlTextSyntax content = SyntaxFactory.XmlText(parameterContent);

			// [2] -- end tag
			XmlElementEndTagSyntax endTag = SyntaxFactory.XmlElementEndTag(paramName);
			return SyntaxFactory.XmlElement(startTag, SyntaxFactory.SingletonList<SyntaxNode>(content), endTag);
		}

Microsoft.CodeAnalysis.VisualBasic.Syntax.XmlElementSyntax : XmlNodeSyntax

Methods :

public XmlElementStartTagSyntax get_StartTag()
public XmlElementSyntax WithStartTag(XmlElementStartTagSyntax startTag = )
public SyntaxList<XmlNodeSyntax> get_Content()
public XmlElementSyntax WithContent(SyntaxList<XmlNodeSyntax> content = )
public XmlElementSyntax AddContent(XmlNodeSyntax[] items = )
public XmlElementEndTagSyntax get_EndTag()
public XmlElementSyntax WithEndTag(XmlElementEndTagSyntax endTag = )
public TResult Accept(VisualBasicSyntaxVisitor<TResult> visitor = )
public Void Accept(VisualBasicSyntaxVisitor visitor = )
public XmlElementSyntax Update(XmlElementStartTagSyntax startTag = , SyntaxList<XmlNodeSyntax> content = , XmlElementEndTagSyntax endTag = )
public SyntaxKind Kind()
public String get_Language()
public String ToString()
public String ToFullString()
public Void WriteTo(TextWriter writer = )
public Void SerializeTo(Stream stream = , CancellationToken cancellationToken = null)
public Boolean get_IsDirective()
public Int32 get_SpanStart()
public SyntaxTriviaList GetLeadingTrivia()
public SyntaxTriviaList GetTrailingTrivia()
public SyntaxToken GetFirstToken(Boolean includeZeroWidth = False, Boolean includeSkipped = False, Boolean includeDirectives = False, Boolean includeDocumentationComments = False)
public SyntaxToken GetLastToken(Boolean includeZeroWidth = False, Boolean includeSkipped = False, Boolean includeDirectives = False, Boolean includeDocumentationComments = False)
public IList<DirectiveTriviaSyntax> GetDirectives(Func<DirectiveTriviaSyntax, Boolean> filter = null)
public DirectiveTriviaSyntax GetFirstDirective(Func<DirectiveTriviaSyntax, Boolean> predicate = null)
public DirectiveTriviaSyntax GetLastDirective(Func<DirectiveTriviaSyntax, Boolean> predicate = null)
public SyntaxNodeOrToken ChildThatContainsPosition(Int32 position = )
public Location GetLocation()
public IEnumerable<Diagnostic> GetDiagnostics()
public SyntaxToken FindToken(Int32 position = , Boolean findInsideTrivia = False)
public SyntaxTrivia FindTrivia(Int32 textPosition = , Boolean findInsideTrivia = False)
public Boolean HasAnnotations(IEnumerable<String> annotationKinds = )
public Boolean HasAnnotation(SyntaxAnnotation annotation = )
public IEnumerable<SyntaxAnnotation> GetAnnotations(String annotationKind = )
public IEnumerable<SyntaxAnnotation> GetAnnotations(IEnumerable<String> annotationKinds = )
public IEnumerable<SyntaxNodeOrToken> GetAnnotatedNodesAndTokens(String annotationKind = )
public IEnumerable<SyntaxNodeOrToken> GetAnnotatedNodesAndTokens(String[] annotationKinds = )
public IEnumerable<SyntaxNodeOrToken> GetAnnotatedNodesAndTokens(SyntaxAnnotation annotation = )
public IEnumerable<SyntaxNode> GetAnnotatedNodes(SyntaxAnnotation syntaxAnnotation = )
public IEnumerable<SyntaxNode> GetAnnotatedNodes(String annotationKind = )
public IEnumerable<SyntaxToken> GetAnnotatedTokens(SyntaxAnnotation syntaxAnnotation = )
public IEnumerable<SyntaxToken> GetAnnotatedTokens(String annotationKind = )
public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia(String annotationKind = )
public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia(String[] annotationKinds = )
public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia(SyntaxAnnotation annotation = )
public T CopyAnnotationsTo(T node = )
public Boolean IsEquivalentTo(SyntaxNode node = , Boolean topLevel = False)
public Int32 get_RawKind()
public SyntaxTree get_SyntaxTree()
public TextSpan get_FullSpan()
public TextSpan get_Span()
public Int32 get_SpanStart()
public SourceText GetText(Encoding encoding = null, SourceHashAlgorithm checksumAlgorithm = Sha1)
public Boolean IsEquivalentTo(SyntaxNode other = )
public Boolean IsIncrementallyIdenticalTo(SyntaxNode other = )
public Boolean get_IsMissing()
public Boolean IsPartOfStructuredTrivia()
public Boolean get_IsStructuredTrivia()
public Boolean get_HasStructuredTrivia()
public Boolean get_ContainsSkippedText()
public Boolean get_ContainsDirectives()
public Boolean get_ContainsDiagnostics()
public Boolean Contains(SyntaxNode node = )
public Boolean get_HasLeadingTrivia()
public Boolean get_HasTrailingTrivia()
public Location GetLocation()
public IEnumerable<Diagnostic> GetDiagnostics()
public SyntaxReference GetReference()
public SyntaxNode get_Parent()
public SyntaxTrivia get_ParentTrivia()
public ChildSyntaxList ChildNodesAndTokens()
public IEnumerable<SyntaxNode> ChildNodes()
public IEnumerable<SyntaxNode> Ancestors(Boolean ascendOutOfTrivia = True)
public IEnumerable<SyntaxNode> AncestorsAndSelf(Boolean ascendOutOfTrivia = True)
public TNode FirstAncestorOrSelf(Func<TNode, Boolean> predicate = null, Boolean ascendOutOfTrivia = True)
public TNode FirstAncestorOrSelf(Func<TNode, TArg, Boolean> predicate = , TArg argument = , Boolean ascendOutOfTrivia = True)
public IEnumerable<SyntaxNode> DescendantNodes(Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public IEnumerable<SyntaxNode> DescendantNodes(TextSpan span = , Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public IEnumerable<SyntaxNode> DescendantNodesAndSelf(Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public IEnumerable<SyntaxNode> DescendantNodesAndSelf(TextSpan span = , Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public IEnumerable<SyntaxNodeOrToken> DescendantNodesAndTokens(Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public IEnumerable<SyntaxNodeOrToken> DescendantNodesAndTokens(TextSpan span = , Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public IEnumerable<SyntaxNodeOrToken> DescendantNodesAndTokensAndSelf(Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public IEnumerable<SyntaxNodeOrToken> DescendantNodesAndTokensAndSelf(TextSpan span = , Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public SyntaxNode FindNode(TextSpan span = , Boolean findInsideTrivia = False, Boolean getInnermostNodeForTie = False)
public SyntaxToken FindToken(Int32 position = , Boolean findInsideTrivia = False)
public SyntaxToken GetFirstToken(Boolean includeZeroWidth = False, Boolean includeSkipped = False, Boolean includeDirectives = False, Boolean includeDocumentationComments = False)
public SyntaxToken GetLastToken(Boolean includeZeroWidth = False, Boolean includeSkipped = False, Boolean includeDirectives = False, Boolean includeDocumentationComments = False)
public IEnumerable<SyntaxToken> ChildTokens()
public IEnumerable<SyntaxToken> DescendantTokens(Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public IEnumerable<SyntaxToken> DescendantTokens(TextSpan span = , Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public SyntaxTriviaList GetLeadingTrivia()
public SyntaxTriviaList GetTrailingTrivia()
public SyntaxTrivia FindTrivia(Int32 position = , Boolean findInsideTrivia = False)
public SyntaxTrivia FindTrivia(Int32 position = , Func<SyntaxTrivia, Boolean> stepInto = )
public IEnumerable<SyntaxTrivia> DescendantTrivia(Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public IEnumerable<SyntaxTrivia> DescendantTrivia(TextSpan span = , Func<SyntaxNode, Boolean> descendIntoChildren = null, Boolean descendIntoTrivia = False)
public Boolean get_ContainsAnnotations()
public Boolean HasAnnotations(String annotationKind = )
public Type GetType()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()