Skip to content
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

Merged
merged 10 commits into from
Apr 10, 2024

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Aug 15, 2022

Fixes #63410

@CyrusNajmabadi What do you think of the fix?

@Youssef1313 Youssef1313 requested a review from a team as a code owner August 15, 2022 22:08
@ghost ghost added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Aug 15, 2022
@Youssef1313 Youssef1313 marked this pull request as draft August 16, 2022 04:49
@Youssef1313 Youssef1313 reopened this Aug 17, 2022
@Youssef1313 Youssef1313 marked this pull request as ready for review August 17, 2022 07:28
@Youssef1313
Copy link
Member Author

@CyrusNajmabadi This is ready for review.

IEnumerable<SyntaxNode>? statements = null)
{
throw new NotImplementedException();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this guy?

Copy link
Member Author

@Youssef1313 Youssef1313 Aug 17, 2022

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.

Copy link
Member

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?

Copy link
Member Author

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:

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)
Copy link
Member

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).

Copy link
Member Author

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.

Copy link
Member

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.

@Youssef1313
Copy link
Member Author

@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,
Copy link
Member

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.

@jcouv
Copy link
Member

jcouv commented Nov 12, 2022

@CyrusNajmabadi Can this be merged?

@jcouv jcouv added this to the 17.5 milestone Nov 12, 2022
@Youssef1313
Copy link
Member Author

@CyrusNajmabadi Can you take a look please? Thanks!

@arkalyanms arkalyanms modified the milestones: 17.5, Backlog Sep 12, 2023
@CyrusNajmabadi CyrusNajmabadi merged commit d60cfab into dotnet:main Apr 10, 2024
27 checks passed
@dotnet-policy-service dotnet-policy-service bot modified the milestones: Backlog, Next Apr 10, 2024
@CyrusNajmabadi
Copy link
Member

Thanks @Youssef1313 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SyntaxGenerator crashes with 'checked' operators
5 participants