-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Update documentation for DeclaringSyntaxReferences and Locations to clarify partial members behavior #80704
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
…larify partial members behavior Co-authored-by: CyrusNajmabadi <[email protected]>
Co-authored-by: CyrusNajmabadi <[email protected]>
|
@dotnet/roslyn-compiler ptal. |
|
I don't understand why this PR didn't automatically get labelled with "Compiler" given that it touches a compiler file. Is there a bot problem? |
|
@dotnet/roslyn-compiler ptal. |
| [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/13456")] | ||
| public void PartialMethodsLocationsAndSyntaxReferences() | ||
| { | ||
| // This test documents the behavior described in https://github.com/dotnet/roslyn/issues/13456 |
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.
Link is wrong #Closed
| } | ||
| }"; | ||
|
|
||
| var comp = CreateCompilation(new[] { source, source2 }); |
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.
nit: it looks like copilot doesn't know about collection expressions yet. Maybe something we can nudge via repo-level instructions? #Closed
| var comp = CreateCompilation(new[] { source, source2 }); | ||
| comp.VerifyDiagnostics(); | ||
|
|
||
| var methodSymbols = comp.GetSymbolsWithName("PartialM"); |
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 is unnecessary lengthy and complicated. Since we know there's only one and it's a method symbol: we can do 1 line, var method = (IMethodSymbol)comp.GetSymbolsWithName("PartialM").Single();, instead of 5 lines #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.
@copilot remove lengthy and complicated assertion checking. Also add to the copilot-instructions file that tests should avoid unnecessary assertations and should do the minimal work necessary to get to the core assertions that validate the issue being addressed.
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.
Simplified test and updated Compiler.instructions.md to guide future tests in commit 2c7c5d9
| Assert.Equal(1, implementationPart.DeclaringSyntaxReferences.Length); | ||
|
|
||
| // Verify the locations are different | ||
| Assert.NotEqual(method.Locations[0], implementationPart.Locations[0]); |
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.
By naming the sources when creating the compilation (CreateCompilation([(source, "source"), (source2, "source2")])) it should be easy to observe each location #Closed
The link in OP is hallucinated #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.
Done with review pass (commit 3)
|
@dotnet/roslyn-compiler ptal. |
| Assert.False(partialImplConstructed.IsPartialDefinition); | ||
| } | ||
|
|
||
| [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/13456")] |
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.
Link is wrong here too #Closed
| var methodSymbols = comp.GetSymbolsWithName("PartialM"); | ||
|
|
||
| var method = (IMethodSymbol)methodSymbols.Single(); | ||
| Assert.NotNull(method); |
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.
Unnecessary assertion #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.
Removed in commit 2c7c5d9
| var comp = CreateCompilation([(source1, "source1"), (source2, "source2")]); | ||
| comp.VerifyDiagnostics(); | ||
|
|
||
| var methodSymbols = comp.GetSymbolsWithName("PartialM"); |
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 inlining methodSymbols since only used once #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.
Inlined in commit 2c7c5d9
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.
Done with review pass (commit 5)
…ion, inline variable, and update instructions Co-authored-by: CyrusNajmabadi <[email protected]>
Co-authored-by: Rikki Gibson <[email protected]>
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 Thanks (commit 8)
* upstream/main: (123 commits) Fix SafeContext of Span-valued collection expressions to match specification (dotnet#80684) Improve detection of invalid references for implicitly typed expression variables declared within implicit object creation expressions. (dotnet#80546) Add test demonstrating behavior of ToMinimalDisplayString. (dotnet#80757) Only set DOTNET_HOST_PATH if something was installed (dotnet#80842) Clean up a Razor external access service (dotnet#80830) Remove unused statement (dotnet#80823) Allow foreach on typed null enumerables (dotnet#80783) Update documentation for DeclaringSyntaxReferences and Locations to clarify partial members behavior (dotnet#80704) Fix issue converting an auto prop to a full prop when 'field' and 'initializers' are involved Rename childIsSimple to innerExpressionHasPrimaryPrecedence and add more test cases Remove placeholder WorkItem attributes from new tests Fix RemoveUnnecessaryParentheses to detect simple expressions in bitwise operations [main] Update dependencies from dotnet/arcade (dotnet#80828) Fix ITypeSymbol.BaseType documentation for type parameters (dotnet#80770) soft-select select camelcase matched item if user might be typing an undefined type parameter (dotnet#80809) Allow semantic tokens in Razor to be better behaved (dotnet#80815) Rebase Remove using Update test Add fix all test ...
Documentation Update for DeclaringSyntaxReferences and Locations
Progress
DeclaringSyntaxReferencesandLocationsfor partial methodsISymbol.Locationsto clarify behavior for partial types vs partial membersISymbol.DeclaringSyntaxReferencesto clarify behavior for partial types vs partial membersChanges Made
Documentation Updates in
ISymbol.csLocationsproperty: Updated documentation to clarify that:PartialDefinitionPartandPartialImplementationPartpropertiesDeclaringSyntaxReferencesproperty: Updated documentation with the same clarificationsTest Added
Added
PartialMethodsLocationsAndSyntaxReferencestest inMethodTests.csthat:LocationsarrayDeclaringSyntaxReferencesarrayPartialImplementationPartInstructions Updated
Updated
.github/instructions/Compiler.instructions.mdto guide future tests to be focused and avoid unnecessary assertions.Build Status
✅ All builds passed
✅ All existing tests passed
✅ New test passed
✅ Code review feedback addressed
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.