-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Would allowing extension methods to be defined in nested classes make sense? #9139
Comments
Yes! This restriction is frustrating once in a while in general and frustrating frequently in C# scripts like Cake, where there is no way to declare an extension method. |
C# scripts have supported extension methods for a while. This is a valid script for example:
|
here is the PR #3472 |
Hmm... thanks for the heads up. The most recent version of Roslyn that Cake uses is |
that's the last version that supported .NET 4.5. it's also almost 2 years old, with 2.0.0 going RTM soon and 2.0.0-rc4 being the latest |
I think this is a duplicate of #4565 (which was moved to dotnet/csharplang#301). |
Why declare it in a nested static class instead of directly in the class?
|
Would you close the issue, please, since all language design issues have migrated to https://github.com/dotnet/csharplang? |
My thinking is that allowing ^ would be a way to scope extension methods to only be visible in
Foo
.Could be nice for extensions on types like string when a limited scope is desired.
I don't remember the reason why extension methods are not allowed in nested classes.
I have not though much about and it may be a bad idea, wrote this to get some feedback.
Would this add much complexity to parsing etc?
The text was updated successfully, but these errors were encountered: