-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Annotated SyntaxList #40729
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
Annotated SyntaxList #40729
Conversation
|
@dotnet/roslyn-compiler PTAL |
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.
SyntaxNode? [](start = 28, length = 11)
When is this null? #Resolved
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.
Most obvious place is here:
public SyntaxList(IEnumerable<TNode>? nodes)
: this(CreateNode(nodes)!)
Which ... I should really remove the ! from cause it's unnecessary. #Resolved
src/Compilers/Core/Portable/Syntax/SyntaxList.SeparatedWithManyChildren.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/Syntax/SyntaxList.SeparatedWithManyChildren.cs
Outdated
Show resolved
Hide resolved
sharwell
left a comment
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.
Done with 9/14 files
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.
💡 Consider splitting the expression list.ItemInternal(i) to a local, then asserting that it is not null. #WontFix
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.
❔ Is it possible for this to reach external code and still be null?
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 that I'm aware of. It's an implementation detail of this type.
In reply to: 362963462 [](ancestors = 362963462)
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.
💡 Consider refactoring this method:
var listNode = builder?.ToListNode();
if (listNode is null)
{
return null;
}
return new SeparatedSyntaxList<TNode>(new SyntaxNodeOrTokenList(listNode.CreateRed(), 0));
Applies to methods above too. #Resolved
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.
That would change the return type of the method to be a nullable struct. That's not a trivial change here.
In reply to: 362969063 [](ancestors = 362969063)
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.
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 I meant return default. ToListNode only returns null if the list is empty, so the checks can all be combined. #Resolved
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.
💡 The implementation allows builder to be null. I accounted for this in my suggested refactoring.
Applies to all methods in this type. #Resolved
sharwell
left a comment
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.
Review complete. If the changes in SyntaxListBuilderExtensions.cs are not implemented as part of this pull request, please file an issue for them since it seems like a good improvement to make.
Co-Authored-By: Sam Harwell <sam@tunnelvisionlabs.com>
The suppression in `SyntaxList` is necessary in order to meet the API contract. Filed an issue for follow up dotnet#40733
It's a good question. One of the tricky parts of nullability is how we treat reference fields inside Overall though I don't think this type of scenario is cut and dry. In reply to: 570725573 [](ancestors = 570725573) Refers to: src/Compilers/Core/Portable/Syntax/SyntaxListBuilder`1.cs:30 in 8e507a5. [](commit_id = 8e507a5, deletion_comment = False) |
No description provided.