Repository navigation
Conversation
|
Thanks for the PR! I'm worried about:
Note on out of scope cross cutting issue: We should possibly be using |
|
|
||
| /// <summary> | ||
| /// A VB method or property declared without Overloads, Overrides or Shadows hides every accessible inherited member | ||
| /// of the same name (case-insensitively, BC40003/BC40004), also in interfaces, whereas C# only hides the same signature. |
There was a problem hiding this comment.
Probably either remove mention of BC40004 or explain the reasoning around what happens, since this method implementation only deals with same kind. It's currently a bit at odds to mention it but then exclude that case without further explanation.
There was a problem hiding this comment.
Removed BC40004. The summary now says why only a member of the same kind counts: VB can't overload a property with a method or the reverse, so such a member stays hidden by name either way.
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.
55d6bf2 to
3829507
Compare
|
Thanks! All three are addressed in a separate commit (3829507):
|
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