fix(csharp): explicit interface implementations are public, not private - #2302
Open
zichen0116 wants to merge 1 commit into
Open
zichen0116 wants to merge 1 commit into
zichen0116 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2164
Problem
Since #1745, cross-file resolution declines candidates whose
visibilityisprivate(they are treated as file-local) — and the C# extractor defaultedevery modifier-less member to
private. That default is wrong for explicitinterface implementations:
void IOrderService.CancelOrder(int id)cannotcarry an access modifier in C# (CS0106), but it is reachable through the
interface, so it must not be treated as file-local.
The two other cases from #2164 (interface members, top-level types) were
already fixed by #2220; this covers the remaining one.
Fix
In the C#
getVisibility, returnpublicwhen the member node carries anexplicit_interface_specifierchild (methods, properties, indexers, events —all share this node shape):
Verification
New regression test
__tests__/csharp-interface-visibility.test.ts(realindexing through the full
CodeGraphpipeline):visibility = public(guard for fix(csharp): namespaces, usings and nested types follow the language's scopes #2220)a parameter, and a primary-constructor parameter in another file) → 3
callsedges toIOrderService::CancelOrder(guard for fix(csharp): namespaces, usings and nested types follow the language's scopes #2220)visibility = private, and a cross-file call to it produced nocallsedge; after:
visibility = publicand the call resolves. The new testfails on the pre-fix tree and passes with the fix.
Also ran: all 5 C# suites (11 tests) pass,
__tests__/extraction.test.ts(691 tests) passes,
tsc --noEmitclean. Added aCHANGELOG.mdentry under[Unreleased]→### Fixesper the repo's changelog rules.