/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Workspaces/CoreTest/UtilityTest/XmlDocumentationProviderTests.cs
47 строк
2 KB
Jason Malinowski
Remove AssertEx.NotNull
21 апр 2026, 23:28
21 апр 2026, 23:28
4c5adf0
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.IO; using System.Text; using System.Xml.Linq; using Microsoft.CodeAnalysis.CSharp; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.UnitTests; public sealed class XmlDocumentationProviderTests { [Fact] public void XmlDocumentationProviderReturnsEntireMemberNode() { var roslynCompilersLocation = typeof(Compilation).Assembly.Location; var roslynCompilersXmlFilePath = Path.ChangeExtension(roslynCompilersLocation, ".xml"); var documentationProvider = XmlDocumentationProvider.CreateFromBytes(Encoding.UTF8.GetBytes(""" <?xml version="1.0"?> <doc> <assembly> <name>Microsoft.CodeAnalysis</name> </assembly> <members> <member name="T:Microsoft.CodeAnalysis.AdditionalTextFile"> <summary> Represents a non source code file. </summary> </member> </members> </doc> """)); var portableExecutableReference = MetadataReference.CreateFromFile(roslynCompilersLocation, documentation: documentationProvider); var compilation = CSharpCompilation.Create(nameof(XmlDocumentationProviderReturnsEntireMemberNode), references: [portableExecutableReference]); // Verify we can parse it and it contains a single node var xml = compilation.GetTypeByMetadataName("Microsoft.CodeAnalysis.AdditionalTextFile")!.GetDocumentationCommentXml(); Assert.NotNull(xml); var xmlDocument = XDocument.Parse(xml); Assert.Equal("member", xmlDocument.Root!.Name.LocalName); Assert.Equal("T:Microsoft.CodeAnalysis.AdditionalTextFile", xmlDocument.Root!.Attribute("name")!.Value); } }