Add native integer keyword recommenders#42976
Add native integer keyword recommenders#42976cston merged 2 commits intodotnet:features/NativeIntfrom
Conversation
| if (context.IsStatementContext || | ||
| context.IsGlobalStatementContext || | ||
| context.IsPossibleTupleContext || | ||
| context.IsPatternContext || |
There was a problem hiding this comment.
- can you add a pattern test and a tuple test.
- also a test that it doesn't appear here
enum e : $$ - what aobut here
nint n = new $$ - not after
as - yes after
is - after
fixed? - in lambda parameter
static operator implicit $$<see cref="$$"/>- after
ref? after const? (unless it's not legal there). i think you have test for this. but check field and local.- after
stackalloc? - return type of a member in a class?
default($$)- not in type parameter constraints.
#Resolved
There was a problem hiding this comment.
need a test for a normal expression location. like var v = 1 + $$. #Resolved
There was a problem hiding this comment.
There was a problem hiding this comment.
also a test that it doesn't appear here enum e : $$
I thought LDM agreed this was fine provided it didn't require unreasonable changes? I can't actually find the notes for that meeting however...
There was a problem hiding this comment.
I thought LDM agreed this was fine provided it didn't require unreasonable changes? I can't actually find the notes for that meeting however...
If so, then add test that it's legal there :)
There was a problem hiding this comment.
Ah, here we go: https://github.com/dotnet/csharplang/blob/3b22aa0b47cc2ab6352e01f73f976fdbbf9d9b2d/meetings/2019/LDM-2019-10-23.md
For use as an enum underlying type, we think nint/nuint should be allowed as long as it's not too much implementation work. The legal values would be the same as the valid constants for the underlying.
There was a problem hiding this comment.
I'll include the enum context when native integers are supported as underlying types in the compiler. For now, the keyword recommender will not include the keywords in that context.
In reply to: 401782265 [](ancestors = 401782265)
| { | ||
| protected abstract RecommendedKeyword Keyword { get; } | ||
|
|
||
| private bool IsValidContext(CSharpSyntaxContext context) |
| { | ||
| internal sealed class NintKeywordRecommender : AbstractNativeIntegerKeywordRecommender | ||
| { | ||
| protected override RecommendedKeyword Keyword => new RecommendedKeyword("nint"); |
There was a problem hiding this comment.
Yes, we can make that change when the feature is included in the build.
In reply to: 401372085 [](ancestors = 401372085)
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
Overall looks fine. Just want to flesh out tests more to interesting cases
| public void AliasName_02() | ||
| { | ||
| var source = | ||
| @"using N = nint; |
There was a problem hiding this comment.
Why does this allowed, but using I = int; isn't? Seems inconsistent.
jcouv
left a comment
There was a problem hiding this comment.
Compiler change (test-only) LGTM Thanks
Relates to #38821 (native ints feature)