-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Extensions: fix GetSymbolInfo within ExtensionMemberCrefSyntax #81722
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
c6f029a to
df2e0f0
Compare
| [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/81710"] | ||
| public void Cref_68() | ||
| { | ||
| var src = """ |
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.
raw string? #Resolved
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.
(indented raw string, rather).
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 formatting is intentional
df2e0f0 to
68e8549
Compare
4ce27e5 to
80a02ea
Compare
|
|
||
| <WpfTheory, CombinatorialData> | ||
| <WorkItem("https://github.com/dotnet/roslyn/issues/81710")> | ||
| Public Async Function FindReferences_ExtensionBlockMethod_Cref(kind As TestKind, host As TestHost) As Task |
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.
nice. i'm glad this just fell out. #Resolved
| var m = ((NameMemberCrefSyntax)extensionCref.Member).Name; | ||
| Assert.Equal("M", m.ToString()); | ||
| AssertEx.Equal("E.extension(int).M(string)", model.GetSymbolInfo(m).Symbol.ToDisplayString()); | ||
| } |
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.
Consider asserting those found symbols are the same (reference equals) between themselves and also with the E.M symbol found outside the doc comment. #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.
Hmm, I don't think there's a requirement that the symbols from semantic model be reference equal. Definitions should be reference equal, but that's not about the semantic model and here we're not dealing with definitions in this test anyways.
| <Workspace> | ||
| <Project Language="C#" CommonReferences="true" LanguageVersion="Preview"> | ||
| <Document> | ||
| /// <see cref="E.extension(int).[|M|]()"/> |
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.
Consider wrapping the code in <![CDATA[]]> instead of xml-encoding parts of it. #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.
I leaned towards this encoding
| AssertEx.Equal("E.extension(int).M(string)", model.GetSymbolInfo(extensionCref).Symbol.ToDisplayString()); | ||
| var m = ((NameMemberCrefSyntax)extensionCref.Member).Name; | ||
| Assert.Equal("M", m.ToString()); | ||
| AssertEx.Equal("E.extension(int).M(string)", model.GetSymbolInfo(m).Symbol.ToDisplayString()); |
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.
Thanks. That uncovered another problem
| public void Cref_68() | ||
| { | ||
| var src = """ | ||
| /// <see cref="E.extension(int).M(string)"/> |
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.
|
|
||
| <WpfTheory, CombinatorialData> | ||
| <WorkItem("https://github.com/dotnet/roslyn/issues/81710")> | ||
| Public Async Function FindReferences_ExtensionBlockMethod_Cref(kind As TestKind, host As TestHost) As Task |
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.
Consider covering all scenarios covered in added compiler test(s)
This thread was resolved, but I do not see any changes made in response. Since these are not compiler tests, I am going to sign off, but I will reactivate the thread in case you resolved it by mistake.
|
Done with review pass (commit 3) |
AlekseyTs
left a comment
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 5)
Closes #81710
The problem in #81710 turns out to be a problem with
GetSymbolInfo.GetSymbolInfoshould succeed in finding the extension member not only when given theE.extension(...).Membersyntax but also just theMemberportion of that syntax.FindReferencesin the IDE makes use of that, as it starts by identifying a symbol of interest, then syntactically tracks all the occurrences of the symbol's name, then queries the semantic model for each instance (seeFindReferencesInTokens) to check which instances actually refer to the given symbol.