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

API proposal for "Using Alias to any Type" #66913

Closed
CyrusNajmabadi opened this issue Feb 16, 2023 · 2 comments
Closed

API proposal for "Using Alias to any Type" #66913

CyrusNajmabadi opened this issue Feb 16, 2023 · 2 comments
Labels
api-approved API was approved in API review, it can be implemented Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@CyrusNajmabadi
Copy link
Member

Championed proposal: dotnet/csharplang#4284
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/using-alias-types.md
Test Plan: #56323

Proposed API

using_directive
-  : 'global'? 'using' ('static' | name_equals)? name ';'
+  : 'global'? 'using' ('static' | ('unsafe'? name_equals))? type ';'
  ;
public sealed class UsingDirectiveSyntax
{
+    public SyntaxToken UnsafeToken { get; }
+    public TypeSyntax Type { get; }

-     public NameSyntax Name { get; }

+    /// <summary>Returns <see cref="Type"/> if it is a <see cref="NameSyntax"/>, null otherwise.</summary>
+    public NameSyntax? Name { get; }

+     // All the Update/With methods
}

public sealed class SyntaxFactory
{
+    public static UsingDirectiveSyntax UsingDirective(NameEqualsSyntax? alias, TypeSyntax type);
+    public static UsingDirectiveSyntax  UsingDirective(
+        SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, SyntaxToken unsafeKeyword,
+        NameEqualsSyntax? alias, TypeSyntax type, SyntaxToken semicolonToken);
}
@CyrusNajmabadi CyrusNajmabadi added Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request labels Feb 16, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 16, 2023
@CyrusNajmabadi CyrusNajmabadi added the api-ready-for-review API is ready for review, it is NOT ready for implementation label Feb 16, 2023
@333fred
Copy link
Member

333fred commented Feb 16, 2023

API Review

  • Have we thought about what we'd need to do if we end up doing generics in alias names?
    • The part that would change is independent of this.
  • Do we want an "expanded using alias" thing to avoid API breaks?
    • Would result in more pain for users than making Name nullable, as everywhere that is currently UsingDirectiveSyntax is now BaseUsingDirectiveSyntax
  • Rename Type to be NamespaceOrType to be more clear
  • Approved

@333fred 333fred added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels Feb 16, 2023
@CyrusNajmabadi
Copy link
Member Author

Closing out as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved in API review, it can be implemented Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants