-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Extensions: DocumentationCommentId and ExtensionGroupingName/ExtensionMarkerName APIs, update grouping type metadata name #80164
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
Conversation
fe339a9
to
c7f70d0
Compare
ExtensionGroupingName/ExtensionMarkerName APIs
c7f70d0
to
2a30d08
Compare
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Extension.cs
Outdated
Show resolved
Hide resolved
Moved APIs down into |
if (symbol.IsExtension) | ||
{ | ||
_builder.Append('.'); | ||
_builder.Append(symbol.ExtensionMarkerName); |
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.
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.
If we are supposed to reflect metadata name here, we should be good, because ExtensionMarkerName
is it.
{ | ||
if (symbol.IsExtension) | ||
{ | ||
return false; |
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.
} | ||
} | ||
|
||
GetMatchingExtensions(container, memberName, results); // Note: the arity is already in the content-based extension grouping name |
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.
} | ||
} | ||
|
||
GetMatchingExtensions(container, memberName, results); |
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.
ImmutableArray<INamedTypeSymbol> unnamedNamedTypes = container.GetTypeMembers(""); | ||
foreach (var namedType in unnamedNamedTypes) | ||
{ | ||
if (namedType.IsExtension && namedType.ExtensionGroupingName == memberName) |
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.
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.
I don't think so Added above. We need to match E.GroupingType.MatchingType
back to the extension
|
||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Diagnostics; |
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 the added using
necessary? #Closed
continue; | ||
} | ||
|
||
var sourceNamedType = (SourceNamedTypeSymbol)type; |
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.
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.
The thread got marked as resolved, but it looks like changes were not reverted.
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.
The code changed below due to moving APIs down to NamedTypeSymbol
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.
The code changed below due to moving APIs down to NamedTypeSymbol
SourceNamedTypeSymbol
is a NamedTypeSymbol
. I think changes in this function are not needed
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.
Then we need to add assertions for nullability
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.
Then we need to add assertions for nullability
I have no objection to that. I do object to rewriting code without an intent to change behavior.
if (symbol.TypeParameters.Length > 0) | ||
if (symbol.TypeParameters.Length > 0 && !symbol.IsExtension) | ||
{ | ||
_builder.Append('`'); |
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.
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.
Using MetadataName
here would be equivalent to using ExtensionMarkerName
, but we want ExtensionGroupingName
here:
- for a member, we'll display
Container.ExtensionGroupingType.Member
- for the extension itself, we'll display
Container.ExtensionGroupingType.ExtensionMarkerType
(the last segment is added by caller who initiates visit on an extension)
} | ||
|
||
private static void GetMatchingTypes(List<INamespaceOrTypeSymbol> containers, string memberName, int arity, List<ISymbol> results) | ||
private static void GetMatchingTypes(List<INamespaceOrTypeSymbol> containers, string memberName, int arity, bool isTerminal, List<ISymbol> results) |
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.
for (int i = 0, n = containers.Count; i < n; i++) | ||
{ | ||
GetMatchingTypes(containers[i], memberName, arity, results); | ||
GetMatchingTypes(containers[i], memberName, arity, isTerminal: isTerminal, results); |
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.
&& container is INamedTypeSymbol { IsExtension: true } extension | ||
&& extension.ExtensionMarkerName == memberName) | ||
{ | ||
results.Add(extension); |
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.
|
||
private static void GetMatchingExtensions(INamespaceOrTypeSymbol container, string memberName, int arity, List<ISymbol> results) | ||
{ | ||
ImmutableArray<INamedTypeSymbol> unnamedNamedTypes = container.GetTypeMembers(""); |
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.
Friend Sub AddExtensionMarkerName(extension As INamedTypeSymbol) | ||
Debug.Assert(extension.IsExtension) | ||
AddNestedTypeSeparator() | ||
Builder.Add(CreatePart(SymbolDisplayPartKind.ClassName, extension, extension.ExtensionMarkerName, True)) |
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.
Are we testing that VB and C# produce the same doc ids for the same entities? I think we need to verify/observe that the issues outlined in dotnet/csharplang#9682 are not present. #Closed |
&& container is INamedTypeSymbol { IsExtension: true } extension | ||
&& extension.ExtensionMarkerName == memberName) | ||
{ | ||
results.Add(extension); |
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.
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.
Yes, each of the new tests does
Done with review pass (commit 8) #Closed |
} | ||
} | ||
|
||
internal void AddExtensionMarkerName(INamedTypeSymbol extension) |
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.
This seems to be used only once. Consider inlining or at least marking private
. #ByDesign
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.
If this is marked as private, then the caller can't call it.
If it's inlined, then we can't use Builder
which is protected.
End If | ||
End Sub | ||
|
||
Friend Sub AddExtensionMarkerName(extension As INamedTypeSymbol) |
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.
Same comment here. #ByDesign
var comp2 = CreateCompilation("", references: [comp.EmitToImageReference()]); | ||
validate(comp2); | ||
|
||
var vbComp = CreateVisualBasicCompilation("", referencedAssemblies: [comp.EmitToImageReference()]); |
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.
var comp2 = CreateCompilation("", references: [comp.EmitToImageReference()]); | ||
validate(comp2); | ||
|
||
var vbComp = CreateVisualBasicCompilation("", referencedAssemblies: [comp.EmitToImageReference()]); |
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.
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.
LGTM (commit 12)
Proposed API design: #80163
Address part of #78957 (extension public API follow-ups)
Based on feedback from API review, I'm moving the API from
ITypeSymbol
down intoINamedTypeSymbol
.Relates to test plan #76130
Filled #80165 for crash in VB test
Note: this was merged into SDK .NET 10 RC2.