示例#1
0
        private static async Task <Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
        {
            SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            var xmlElement = (XmlElementSyntax)root.FindNode(diagnostic.Location.SourceSpan, findInsideTrivia: true, getInnermostNodeForTie: true);

            var newXmlElement = XmlSyntaxFactory.ParamRefElement(xmlElement.Content.ToFullString()).WithTriviaFrom(xmlElement);

            return(document.WithSyntaxRoot(root.ReplaceNode(xmlElement, newXmlElement)));
        }
        public void TestParamRefElement()
        {
            string expected = "<paramref name=\"parameterName\"/>";

            Assert.Equal(expected, XmlSyntaxFactory.ParamRefElement("parameterName").ToFullString());
        }