Extensions: DocumentationCommentId and ExtensionGroupingName/ExtensionMarkerName APIs, update grouping type metadata name#80164
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.
If we are supposed to reflect metadata name here, we should be good, because ExtensionMarkerName is it.
| { | ||
| if (symbol.IsExtension) | ||
| { | ||
| return false; |
| } | ||
| } | ||
|
|
||
| GetMatchingExtensions(container, memberName, results); // Note: the arity is already in the content-based extension grouping name |
| } | ||
| } | ||
|
|
||
| GetMatchingExtensions(container, memberName, results); |
| ImmutableArray<INamedTypeSymbol> unnamedNamedTypes = container.GetTypeMembers(""); | ||
| foreach (var namedType in unnamedNamedTypes) | ||
| { | ||
| if (namedType.IsExtension && namedType.ExtensionGroupingName == memberName) |
There was a problem hiding this comment.
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.
Is the added using necessary? #Closed
| continue; | ||
| } | ||
|
|
||
| var sourceNamedType = (SourceNamedTypeSymbol)type; |
There was a problem hiding this comment.
The thread got marked as resolved, but it looks like changes were not reverted.
There was a problem hiding this comment.
The code changed below due to moving APIs down to NamedTypeSymbol
There was a problem hiding this comment.
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.
Then we need to add assertions for nullability
There was a problem hiding this comment.
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.
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 GetMatchingExtensions(INamespaceOrTypeSymbol container, string memberName, int arity, List<ISymbol> results) | ||
| { | ||
| ImmutableArray<INamedTypeSymbol> unnamedNamedTypes = container.GetTypeMembers(""); |
| Friend Sub AddExtensionMarkerName(extension As INamedTypeSymbol) | ||
| Debug.Assert(extension.IsExtension) | ||
| AddNestedTypeSeparator() | ||
| Builder.Add(CreatePart(SymbolDisplayPartKind.ClassName, extension, extension.ExtensionMarkerName, True)) |
|
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.
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.
This seems to be used only once. Consider inlining or at least marking private. #ByDesign
There was a problem hiding this comment.
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.
Same comment here. #ByDesign
| var comp2 = CreateCompilation("", references: [comp.EmitToImageReference()]); | ||
| validate(comp2); | ||
|
|
||
| var vbComp = CreateVisualBasicCompilation("", referencedAssemblies: [comp.EmitToImageReference()]); |
| var comp2 = CreateCompilation("", references: [comp.EmitToImageReference()]); | ||
| validate(comp2); | ||
|
|
||
| var vbComp = CreateVisualBasicCompilation("", referencedAssemblies: [comp.EmitToImageReference()]); |
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
ITypeSymboldown intoINamedTypeSymbol.Relates to test plan #76130
Filled #80165 for crash in VB test
Note: this was merged into SDK .NET 10 RC2.