-
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
Add support for using alias = any_type
.
#50167
Add support for using alias = any_type
.
#50167
Conversation
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using alias = type
to the language.using alias = type
to the language.
@jaredpar 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. |
@cston anything else you'd like? |
src/Compilers/CSharp/Test/Syntax/Parsing/UsingDirectiveParsingTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/TopLevelStatementsParsingTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/UsingDirectiveParsingTests.cs
Outdated
Show resolved
Hide resolved
@cston all feedback responded to. |
There was a problem hiding this 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.
Thanks! 🧙 😄 |
Relates to championed proposal dotnet/csharplang#4284
Relates to spec https://github.com/dotnet/csharplang/blob/main/proposals/using-alias-types.md
Relates to test plan #56323