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

[Proposal] Allow defining local aliases for types #3306

Closed
VBAndCs opened this issue Mar 25, 2020 · 5 comments
Closed

[Proposal] Allow defining local aliases for types #3306

VBAndCs opened this issue Mar 25, 2020 · 5 comments

Comments

@VBAndCs
Copy link

VBAndCs commented Mar 25, 2020

I came across this code:

public List<Expression<Func<T, object>>> Includes { get; } = new List<Expression<Func<T, object>>>();

And I wondered: Can't I simplify this to:

using Expr = Expression<Func<T, object>>

public List<Expr> Includes { get; } = new List< Expr>();

This seems readable.
But unfortunately it is not possible, since T exists only inside the class scope, and using exists only in file/namespace scope!

So, I wish if C# allows using type aliases inside classes. This is a must in today's projects that contain very complex generics and lambdas that make our heads spin.

@Joe4evr
Copy link
Contributor

Joe4evr commented Mar 25, 2020

Duplicate of #2488, #1170, #410 and #259.

@VBAndCs
Copy link
Author

VBAndCs commented Mar 25, 2020

Seems a popular demand :)

@VBAndCs
Copy link
Author

VBAndCs commented Mar 25, 2020

Too many votes for those proposals, yet none is a champion!

@theunrepentantgeek
Copy link

theunrepentantgeek commented Mar 25, 2020

Development of C# isn't a democracy - votes on issues merely show what's popular, not what's good.

The LDM decides on what goes into the next version of the language - and they take into account a far wider range of inputs than just this repo.

Someone pointed out (I think it was @CyrusNajmabadi, but I'm not 100% sure) that the feedback in this repo is less than the statistical noise in feedback through other channels. Fortunately, the LDM takes a special interest in what's said here because many of the contributors take the time to carefully think through issues instead of just banging on their own drum.

@YairHalberstadt
Copy link
Contributor

YairHalberstadt commented Nov 24, 2020

Closing as duplicate between #2488, #1170, #410 and #259.

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

4 participants