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 adding null checks to records. #59404
Conversation
@@ -29,18 +29,27 @@ internal abstract partial class AbstractInitializeParameterCodeRefactoringProvid | |||
where TStatementSyntax : SyntaxNode | |||
where TExpressionSyntax : SyntaxNode | |||
{ | |||
private readonly Func<SyntaxNode, bool> _isFunctionDeclarationFunc; | |||
protected readonly Func<SyntaxNode, bool> _isFunctionDeclarationFunc; | |||
protected readonly Func<SyntaxNode, bool> _isRecordDeclarationFunc; |
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.
With the compiler change about caching method groups, do we need to bother with the protected fields any more, versus just referencing the methods directly?
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 is not a static method, so we'd still need this manual caching
protected override ISyntaxFacts SyntaxFacts | ||
=> CSharpSyntaxFacts.Instance; | ||
|
||
protected override bool SupportsRecords(ParseOptions options) |
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.
I didn't understand this bit. It seems like a primary constructor parameter is perfectly valid to use to initialize a member. It just has to be in a field initializer. Maybe the refactoring isn't intended for that scenario?
record Rec(int X)
{
public int X; // can offer `= X;` refactoring here?
}
Fixes #58779