-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Create using-alias-types.md #5174
Conversation
``` | ||
using_alias_directive | ||
- : 'using' identifier '=' namespace_or_type_name ';' | ||
+ : 'using' identifier '=' (namespace_name | type) ';' |
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.
Does type
include top-level nullability annotation?
I assume this allows built-in types using Id = int;
. Is that right?
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.
Does type include top-level nullability annotation?
Yes. It would.
I assume this allows built-in types using Id = int;. Is that right?
yes, it would.
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.
Yes. It would [include top-level nullability annotation].
From our offline discussion, this raises a question for how the three annotations (?
, !
and ~
/oblivious) interact in the declaration versus the use-site. For example, what happens if you put ?
in the declaration and the use-site?
See also #4452. |
This is very intentionally not trying to support the case of |
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.
Spec looks good to me. Do we have a championed issue?
@CyrusNajmabadi, would this also work for other aliases? That is, could I do the following? using HANDLE = void*;
using HWND = HANDLE; I was wanting to add a feature to the ClangSharp P/Invoke generator that generates
|
The first is completely allowed. The second would not be allowed as a using directive cannot reference another using directive in the same block. However, this is ok: using HANDLE = void*;
namespace X
{
using HWND = HANDLE;
} or using HANDLE = void*;
using HWND = void*;
Keywords would be fine.
You will be able to use pointers.
If in the same scope this will continue to not work and you'll still have to explicitly write out the entire type signature again. |
Awesome.
This is a bit unfortunate but also not overly complex to handle, thankfully. |
Understood. Note that i'm not opposed to work here. But i would consider it more of a separate feature. |
Yep definitely understand. Its basically just traversing the typedefs to the "concrete" type for ClangSharp, I expect its a bit more complex for Roslyn to handle 😄 |
No description provided.