Permit Member Names to be the same as Class Names #3314
Replies: 3 comments
-
How would this impact name resolution? For example: public class Foo
{
public Bar Foo;
public static int Bazz;
public int M() => Foo.Bazz; // Is this the static field on the class `Foo` or the instance field in the field `Foo`?
}
public class Bar
{
public int Bazz
} |
Beta Was this translation helpful? Give feedback.
-
I would imagine it would resolve to the static field, and the member could be accessed by using |
Beta Was this translation helpful? Give feedback.
-
Name resolution would work like this case:
All of my intended users are code generators that spit out C# code, so fully qualifying all the name references is no issue. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Permit Member Names to be the same as Class Names
There's a lot of debate online about "Why do you want this?' Well, there are plenty of good reasons.
Object Mapper
CREATE TABLE LocalizedText (
LanguageId INTEGER NOT NULL,
StringId INTEGER NOT NULL,
LocalizedText NVARCHAR(max) NOT NULL
);
The corresponding C# object really wants to be
While we originally debated syntax with methods, this really only comes up with methods on functor objects.
And there's the classic chestnut for autoconverting VB .NET:
We used to have the following, but they don't exist anymore (when extract to library finally happened they ended up as two different methods in two different files on the same class):
Beta Was this translation helpful? Give feedback.
All reactions