Skip to content

Fix SyntaxGenerator for checked operators#63411

Merged
CyrusNajmabadi merged 10 commits intodotnet:mainfrom
Youssef1313:issues/63410
Apr 10, 2024
Merged

Fix SyntaxGenerator for checked operators#63411
CyrusNajmabadi merged 10 commits intodotnet:mainfrom
Youssef1313:issues/63410

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 Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels 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
Contributor

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
Contributor

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
Contributor

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
Contributor

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.

}

private protected abstract SyntaxNode OperatorDeclaration(
int syntaxKind,
Copy link
Contributor

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!

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

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