[Proposal]: Extensions as static types #8843
Replies: 8 comments
-
Please ship it already in C# 13!!! Or in the first preview of C# 14, if possible 🙂 |
Beta Was this translation helpful? Give feedback.
-
As long as it doesn't compromise future designs (which it doesn't see to, considering it can be "expanded" to non-static later), I'm all for this as well. In a sense, this is similar to " |
Beta Was this translation helpful? Give feedback.
-
Neither of those things are likely to happen. |
Beta Was this translation helpful? Give feedback.
-
My only question might be how this would play for helper methods. Could a private extension method be in scope within the extension that could be called from other extension members? e.g.: public extension StringExtensions for string {
public void M() {
this.HelperMethod();
}
private void HelperMethod() { }
} or would you be expected to declare that helper method as a static method, like we do with extension methods today? public extension StringExtensions for string {
public void M() {
HelperMethod(this);
}
private static void HelperMethod(string value) { }
} The former would be nice... |
Beta Was this translation helpful? Give feedback.
-
I I'm not sure why the prohibition of:
Necessitates the change to how |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Regarding the disambiguation section- will it not be possible to do: |
Beta Was this translation helpful? Give feedback.
-
I'm not sure I understand the logic here. Let's imagine |
Beta Was this translation helpful? Give feedback.
-
Extensions as static types
This has been moved to https://github.com/dotnet/csharplang/blob/main/meetings/working-groups/extensions/extensions-as-static-types.md.
Beta Was this translation helpful? Give feedback.
All reactions