Draft
Conversation
This PR updates the sample code and text output to match the current compiler output.
Member
Author
|
@jcouv This changes matches what I'm seeing in the latest compiler. Can you verify? |
Member
Author
|
/cc @huangmin-ms |
jcouv
reviewed
May 30, 2025
| </member> | ||
| <member name="M:E.M``2(``0,``1)"> | ||
| <inheritdoc cref="M:E.<>E__0`1.M``1(``0)"/> | ||
| <member name="M:ClassLibrary6.E..AddValue(System.Int32)"> |
Member
There was a problem hiding this comment.
This is the wrong expectation. The correct output is <member name="M:ClassLibrary6.E.<>E__0.AddValue(System.Int32)">.
The same comment applies elsewhere: the extension block should appear with its synthesized name (<>E__ followed by an index) and the synthesized name should be escaped (fix pending).
Member
There was a problem hiding this comment.
The metadata design for extensions was updated to use content-based grouping and marker type names. Here's an updated example showing the impact on xml docs:
[Fact]
public void XmlDoc_01()
{
// Instance members
var src = """
/// <summary>Summary for E</summary>
static class E
{
/// <summary>Summary for extension block</summary>
/// <typeparam name="T">Description for T</typeparam>
/// <param name="t">Description for t</param>
extension<T>(T t)
{
/// <summary>Summary for M</summary>
/// <typeparam name="U">Description for U</typeparam>
/// <param name="u">Description for u</param>
public void M<U>(U u) => throw null!;
/// <summary>Summary for P</summary>
public int P => 0;
}
}
""";
var comp = CreateCompilation(src, parseOptions: TestOptions.RegularPreviewWithDocumentationComments, assemblyName: "Test");
comp.VerifyEmitDiagnostics();
var e = comp.GetMember<NamedTypeSymbol>("E");
AssertEx.Equal("""
<member name="T:E">
<summary>Summary for E</summary>
</member>
""", e.GetDocumentationCommentXml());
var extension = e.GetTypeMembers().Single();
AssertEx.Equal("T:E.<G>$8048A6C8BE30A622530249B904B537EB.<M>$D1693D81A12E8DED4ED68FE22D9E856F", extension.GetDocumentationCommentId());
AssertEx.Equal("""
<member name="T:E.<G>$8048A6C8BE30A622530249B904B537EB.<M>$D1693D81A12E8DED4ED68FE22D9E856F">
<summary>Summary for extension block</summary>
<typeparam name="T">Description for T</typeparam>
<param name="t">Description for t</param>
</member>
""", extension.GetDocumentationCommentXml());
var mSkeleton = extension.GetMember<MethodSymbol>("M");
AssertEx.Equal("""
<member name="M:E.<G>$8048A6C8BE30A622530249B904B537EB.M``1(``0)">
<summary>Summary for M</summary>
<typeparam name="U">Description for U</typeparam>
<param name="u">Description for u</param>
</member>
""", mSkeleton.GetDocumentationCommentXml());
var mImplementation = e.GetMember<MethodSymbol>("M");
AssertEx.Equal("""
<member name="M:E.M``2(``0,``1)">
<inheritdoc cref="M:E.<G>$8048A6C8BE30A622530249B904B537EB.M``1(``0)"/>
</member>
""", mImplementation.GetDocumentationCommentXml());
var p = extension.GetMember<PropertySymbol>("P");
AssertEx.Equal("""
<member name="P:E.<G>$8048A6C8BE30A622530249B904B537EB.P">
<summary>Summary for P</summary>
</member>
""", p.GetDocumentationCommentXml());
var pGetImplementation = e.GetMember<MethodSymbol>("get_P");
AssertEx.Equal("""
<member name="M:E.get_P``1(``0)">
<inheritdoc cref="P:E.<G>$8048A6C8BE30A622530249B904B537EB.P"/>
</member>
""", pGetImplementation.GetDocumentationCommentXml());
var expected = """
<?xml version="1.0"?>
<doc>
<assembly>
<name>Test</name>
</assembly>
<members>
<member name="T:E">
<summary>Summary for E</summary>
</member>
<member name="M:E.M``2(``0,``1)">
<inheritdoc cref="M:E.<G>$8048A6C8BE30A622530249B904B537EB.M``1(``0)"/>
</member>
<member name="M:E.get_P``1(``0)">
<inheritdoc cref="P:E.<G>$8048A6C8BE30A622530249B904B537EB.P"/>
</member>
<member name="T:E.<G>$8048A6C8BE30A622530249B904B537EB.<M>$D1693D81A12E8DED4ED68FE22D9E856F">
<summary>Summary for extension block</summary>
<typeparam name="T">Description for T</typeparam>
<param name="t">Description for t</param>
</member>
<member name="M:E.<G>$8048A6C8BE30A622530249B904B537EB.M``1(``0)">
<summary>Summary for M</summary>
<typeparam name="U">Description for U</typeparam>
<param name="u">Description for u</param>
</member>
<member name="P:E.<G>$8048A6C8BE30A622530249B904B537EB.P">
<summary>Summary for P</summary>
</member>
</members>
</doc>
""";
AssertEx.Equal(expected, GetDocumentationCommentText(comp));
var tree = comp.SyntaxTrees.Single();
var model = comp.GetSemanticModel(tree);
AssertEx.SequenceEqual(["(T, T)", "(t, T t)", "(U, U)", "(u, U u)"], PrintXmlNameSymbols(tree, model));
}
Member
Author
|
Converting to draft. I'll update after dotnet/roslyn#78735 gets merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates the sample code and text output to match the current compiler output.