-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Fix SyntaxGenerator for checked operators #63411
Conversation
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
Outdated
Show resolved
Hide resolved
@CyrusNajmabadi This is ready for review. |
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
Outdated
Show resolved
Hide resolved
IEnumerable<SyntaxNode>? statements = null) | ||
{ | ||
throw new NotImplementedException(); | ||
} |
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.
what's this guy?
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.
@CyrusNajmabadi A new method that allows me to pass isChecked
. I couldn't think of another good way.
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 makes sense. w hy is this virtual though and not abstract?
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 incorrectly assumed the type is subclass-able when I saw this:
roslyn/src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs
Lines 194 to 203 in 8f96b1b
public virtual SyntaxNode OperatorDeclaration( | |
OperatorKind kind, | |
IEnumerable<SyntaxNode>? parameters = null, | |
SyntaxNode? returnType = null, | |
Accessibility accessibility = Accessibility.NotApplicable, | |
DeclarationModifiers modifiers = default, | |
IEnumerable<SyntaxNode>? statements = null) | |
{ | |
throw new NotImplementedException(); | |
} |
Given there are already non-public abstract methods, it's indeed okay to make the new methods abstract.
This is fixed in the last commit now.
Co-authored-by: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
WellKnownMemberNames.UnaryPlusOperatorName => OperatorKind.UnaryPlus, | ||
_ => throw new ArgumentException("Unknown operator kind."), | ||
}; | ||
private protected virtual int GetOperatorSyntaxKind(IMethodSymbol method, out bool isChecked) |
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.
why virtual and not abstract (applies to all methods like this).
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.
@CyrusNajmabadi SyntaxGenerator is public. Adding new abstract members is breaking.
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.
SyntaxGenerator has internal-abstracts. It cannot be publicly subclassed :) you're fine adding a new abstract to it.
@CyrusNajmabadi This is ready for another look. |
@@ -202,18 +202,36 @@ internal SyntaxNode MethodDeclaration(IMethodSymbol method, string name, IEnumer | |||
throw new NotImplementedException(); | |||
} | |||
|
|||
private protected abstract SyntaxNode OperatorDeclaration( | |||
int syntaxKind, |
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 think i'd prefer just passing hte operator name along. thsi also includes 'checked' so it can subsume the first two parameters.
@CyrusNajmabadi Can this be merged? |
@CyrusNajmabadi Can you take a look please? Thanks! |
Thanks @Youssef1313 :) |
Fixes #63410
@CyrusNajmabadi What do you think of the fix?