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

Add support for using alias = any_type. #50167

Merged

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Dec 29, 2020

@CyrusNajmabadi
Copy link
Member Author

Tagging @agocke @333fred . Here's my approach for dotnet/csharplang#4284. It allows us to fit this capability into our existing syntax model. It's also an extremely tiny change for the compiler. The cost is mostly just in testing, and likely reducing some IDE assumptions about what teh RHS is for a using-alias.

@@ -215,6 +215,8 @@ internal enum MessageID
IDS_Return = MessageBase + 12790,
IDS_FeatureVarianceSafetyForStaticInterfaceMembers = MessageBase + 12791,
IDS_FeatureConstantInterpolatedStrings = MessageBase + 12792,

IDS_FeatureUsingTypeAlias = MessageBase + 12800,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure hte number to pick here. i could make this 12793 if that's appropriate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This number is fine. It may need to be adjusted when merging to main, but likely there won't be a conflict.

if (name.IsMissing && this.PeekToken(1).Kind == SyntaxKind.SemicolonToken)
type = alias == null ? this.ParseQualifiedName() : this.ParseType();
if (type is not NameSyntax)
type = CheckFeatureAvailability(type, MessageID.IDS_FeatureUsingTypeAlias);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: we could ParseType universally, but then give a specific error if it's not a named type for normal using directives. However, the upside of this appraoch is that someone can always assume if they have a normal using directive or using static directive that there is a name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CyrusNajmabadi CyrusNajmabadi changed the title Demonstration of how to potentially add using alias = type to the language. Prototype of how to potentially add using alias = type to the language. Dec 30, 2020
@CyrusNajmabadi
Copy link
Member Author

FYI @cston @jaredpar Here's my approach about how we could add using X = any_type; to the compiler in a clean fashion. I'm hoping we can build off of this to the final compielr work.

Base automatically changed from master to main March 3, 2021 23:53
@CyrusNajmabadi
Copy link
Member Author

@jaredpar do you know what the next steps woudl be here?

@jaredpar
Copy link
Member

do you know what the next steps woudl be here?

Mostly at this point its' waiting a bit. From a design stand point there are still some issues to tackle on this feature. From a resource stand point we are over booked at the moment. In addition to the feature we've committed to delivering in C# 10 we've recently picked up some C# IDE work that is causing us to potentially shift other work into post C# 10.

This feature is looking more likely for C# 11 at this point. Once we get out from under some of our existing commitments we can come back to this and look to getting it reviewed and put into a feature branch.

@CyrusNajmabadi
Copy link
Member Author

@cston anything else you'd like?

@CyrusNajmabadi
Copy link
Member Author

@cston all feedback responded to.

Copy link
Member

@cston cston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please squash commits when merging.

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge (squash) February 2, 2023 21:50
@CyrusNajmabadi
Copy link
Member Author

image

:)

@jcouv
Copy link
Member

jcouv commented Feb 2, 2023

Thanks! 🧙 😄

@CyrusNajmabadi CyrusNajmabadi merged commit c8d3925 into dotnet:features/UsingAliasesTypes Feb 3, 2023
@CyrusNajmabadi CyrusNajmabadi deleted the usingAliasType branch February 3, 2023 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants