Skip to content
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

Extension properties, fields and operators #205

Open
ghost opened this issue Nov 26, 2017 · 8 comments
Open

Extension properties, fields and operators #205

ghost opened this issue Nov 26, 2017 · 8 comments

Comments

@ghost
Copy link

ghost commented Nov 26, 2017

A long time ago Extension Methods were added to C# and VB.
I propose to add extension properties and extension fields too.

@reduckted
Copy link
Contributor

#73

@ghost
Copy link
Author

ghost commented Nov 27, 2017

#114 would be easy if Extension Operators are implemented.

@ghost ghost changed the title Extension properties and fields Extension properties, fields and operators Nov 27, 2017
@ghost
Copy link
Author

ghost commented Nov 27, 2017

#204 might be unnecessary when everything can be extended by extensions, but it should then be possible to shadow an existing method, property, etc with an extension method.

@Bill-McC
Copy link

Bill-McC commented Nov 27, 2017 via email

@reduckted
Copy link
Contributor

That's correct. You will never ever be able to shadow an instance method by using an extension method.

When an in-scope instance method has a signature that is compatible with the arguments of a calling statement, the instance method is chosen in preference to any extension method. The instance method has precedence even if the extension method is a better match.

From Extension Methods, Instance Methods, and Properties.

@ghost
Copy link
Author

ghost commented Nov 27, 2017

And I agree with it; as you describe, the side effects of shadowing extensions are unacceptable.
EDI 3 days later
I thought about it and I think it would be save when a shadowing extension is only allowed when defined as Friend (assembly scope).

@ghost
Copy link
Author

ghost commented Feb 20, 2018

@KathleenDollard
Copy link
Contributor

This is a great idea, and is being discussed. Happily, this has a Roslyn proposal. If that moves forward, extending :-) it to VB should be straightforward.

More recent than dotnet/roslyn#6136 is dotnet/roslyn#11159

@ghost ghost closed this as completed Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants