-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Extensions: xml docs #78365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extensions: xml docs #78365
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,17 @@ | |
|
||
using System.Collections.Immutable; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Threading; | ||
using Microsoft.CodeAnalysis.CSharp.Emit; | ||
using Microsoft.CodeAnalysis.PooledObjects; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.Symbols | ||
{ | ||
internal sealed class SourceExtensionImplementationMethodSymbol : RewrittenMethodSymbol // Tracked by https://github.com/dotnet/roslyn/issues/76130 : Do we need to implement ISynthesizedMethodBodyImplementationSymbol? | ||
{ | ||
private string? lazyDocComment; | ||
|
||
public SourceExtensionImplementationMethodSymbol(MethodSymbol sourceMethod) | ||
: base(sourceMethod, TypeMap.Empty, sourceMethod.ContainingType.TypeParameters.Concat(sourceMethod.TypeParameters)) | ||
{ | ||
|
@@ -57,8 +61,6 @@ internal override int ParameterCount | |
public sealed override DllImportData? GetDllImportData() => null; | ||
internal sealed override bool IsExternal => false; | ||
|
||
// Tracked by https://github.com/dotnet/roslyn/issues/76130 : How doc comments are supposed to work? GetDocumentationCommentXml | ||
|
||
internal sealed override bool IsDeclaredReadOnly => false; | ||
|
||
public sealed override Symbol ContainingSymbol => _originalMethod.ContainingType.ContainingSymbol; | ||
|
@@ -131,6 +133,20 @@ internal override int TryGetOverloadResolutionPriority() | |
return UnderlyingMethod.TryGetOverloadResolutionPriority(); | ||
} | ||
|
||
public override string GetDocumentationCommentXml(CultureInfo? preferredCulture = null, bool expandIncludes = false, CancellationToken cancellationToken = default) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's multiple direct tests ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, the effect of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added an assertion |
||
{ | ||
// Neither the culture nor the expandIncludes affect the XML for extension implementation methods. | ||
string result = SourceDocumentationCommentUtils.GetAndCacheDocumentationComment(this, expandIncludes: false, ref lazyDocComment); | ||
|
||
#if DEBUG | ||
string? ignored = null; | ||
string withIncludes = SourceDocumentationCommentUtils.GetAndCacheDocumentationComment(this, expandIncludes: true, lazyXmlText: ref ignored); | ||
Debug.Assert(string.Equals(result, withIncludes, System.StringComparison.Ordinal)); | ||
#endif | ||
|
||
return result; | ||
} | ||
|
||
private sealed class ExtensionMetadataMethodParameterSymbol : RewrittenMethodParameterSymbol | ||
{ | ||
public ExtensionMetadataMethodParameterSymbol(SourceExtensionImplementationMethodSymbol containingMethod, ParameterSymbol sourceParameter) : | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a real need for this condition? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From an implementation perspective, this condition ensures that
<param name="extensionParameter">
may only be placed on the extension block. This is shown inXmlDoc_Param_03
.From a language perspective, this rule ensures that you don't end up with two
<param>
tags for the extension parameter (one on the extension block and one on a member). I think allowing such duplicates would make consumption of the resulting xml more difficult than it needs to be.