Repository navigation
Conversation
Member
|
Thanks for the PR! I'm worried about:
Note on out of scope cross cutting issue: We should possibly be using |
A VB method or property without Overloads hides every inherited member of the
same name, while C# only hides the same signature. The converter added
Overloads only next to an override of the same name in the same type, so:
- `Equals(Item x, Item y)` of an IEqualityComparer hid Object.Equals(Object,
Object), and `x.Name == y.Name` converted to `Equals(x.Name, y.Name)` bound
to the comparer's own method (BC30311);
- a derived indexer hid the base indexer (`this["a"]` failed to compile);
- in a derived interface, `Run(string)` hid `Run(int)` of the base interface,
and with Option Strict Off `d.Run(1)` silently called `Run("1")`.
Overloads is now added to an ordinary method or a non-explicit property
(including indexers, compared by metadata name "Item") when an accessible
member of the same kind and name (ignoring case) is inherited from a base
class or, for an interface, a base interface. Members of a static class that
becomes a Module are skipped: a Module inherits nothing and doesn't allow
Overloads (BC36917).
- Cache the accessible inherited members of a type by name, so a type with
many members reads its base types once instead of once per member.
- Compare names with CaseInsensitiveComparison, as VB does.
- Declare an indexer under its metadata name, so [IndexerName("Chars")]
gives `Default Property Chars` rather than `Item`, and the Overloads check
compares the names VB actually declares. Explicit implementations keep
`Item`, bound through Implements.
- Explain why only an inherited member of the same kind counts.
Alexilia
force-pushed
the
fix/overloads-base-members
branch
from
November 24, 2026 20:16
55d6bf2 to
3829507
Compare
Contributor
Author
|
Thanks! All three are addressed in a separate commit (3829507):
|
| private static SyntaxToken WithIndexerName(SyntaxToken id, IPropertySymbol indexer) | ||
| { | ||
| if (indexer == null || !indexer.ExplicitInterfaceImplementations.IsEmpty || indexer.MetadataName == id.ValueText) return id; | ||
| return id.CopyAnnotationsTo(SyntaxFactory.Identifier(id.LeadingTrivia, indexer.MetadataName, id.TrailingTrivia)); |
Member
There was a problem hiding this comment.
CommonConversions.Identifier centralises the work of escaping keywords
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.
Problem
A VB method or property without
Overloadshides every inherited member of the same name, while C# only hides the same signature. The converter addedOverloadsonly next to anoverrideof the same name in the same type, so:IEqualityComparer<T>.Equals(T, T)hidObject.Equals(Object, Object), andx.Name == y.Nameinside it (Equals(x.Name, y.Name)) failed with BC30311;d.Run(1)silently calledRun(String).Solution
Overloadsis added to methods, properties and indexers when an accessible member of the same kind and name (ignoring case) is inherited from a base class or base interface. Members of static classes (VB modules) are skipped, asOverloadsisn't allowed there.Process