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

Don't place 'async' after 'partial' modifier #76168

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #63404

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner November 30, 2024 02:02
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 30, 2024
@@ -177,7 +180,21 @@ private static bool IsIEnumerator(ITypeSymbol returnType, KnownTaskTypes knownTy
private static (SyntaxTokenList newModifiers, TypeSyntax newReturnType) AddAsyncModifierWithCorrectedTrivia(SyntaxTokenList modifiers, TypeSyntax returnType)
{
if (modifiers.Any())
return (modifiers.Add(s_asyncKeywordWithSpace), returnType);
{
// 'partial' modifier must say at the end of the modifiers arrays.
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 await completion that I implemented may have the exact same bug. The bug is more critical for IntelliSense I think.

Copy link
Member

Choose a reason for hiding this comment

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

protected override int GetAsyncKeywordInsertionPosition(SyntaxNode declaration)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @Youssef1313 . I'm going to handle in a followup pr.

return (modifiers.Add(s_asyncKeywordWithSpace), returnType);
{
// 'partial' modifier must say at the end of the modifiers arrays.
var partialModifier = modifiers.FirstOrDefault(static m => m.IsKind(SyntaxKind.PartialKeyword));
Copy link
Contributor

Choose a reason for hiding this comment

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

FirstOrDefault

isn't there an indexof that takes in a kind to find?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope!

Copy link
Contributor

Choose a reason for hiding this comment

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

What about this, it's internal, but I thought it would be accessible? Works the way you have it, and I know the lists are small, but it seems weird to always search to find it.

Copy link
Member Author

Choose a reason for hiding this comment

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

What about this, it's internal,

Nope. That's in compiler layer. We don't have IVT to them. We could make an extension at workspace layer, and update to that. i empower you :)

Copy link
Member

@Youssef1313 Youssef1313 Dec 3, 2024

Choose a reason for hiding this comment

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

Isn't it already exposed as an extension method by the compiler itself?

public static int IndexOf(this SyntaxTokenList list, SyntaxKind kind)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good find

@@ -177,7 +180,21 @@ private static bool IsIEnumerator(ITypeSymbol returnType, KnownTaskTypes knownTy
private static (SyntaxTokenList newModifiers, TypeSyntax newReturnType) AddAsyncModifierWithCorrectedTrivia(SyntaxTokenList modifiers, TypeSyntax returnType)
{
if (modifiers.Any())
return (modifiers.Add(s_asyncKeywordWithSpace), returnType);
{
// 'partial' modifier must say at the end of the modifiers arrays.
Copy link
Contributor

Choose a reason for hiding this comment

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

say

nit: stay

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

@CyrusNajmabadi CyrusNajmabadi merged commit 98fbf2f into dotnet:main Dec 3, 2024
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the makeAsyncPartial branch December 3, 2024 15:41
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Dec 3, 2024
@CyrusNajmabadi CyrusNajmabadi requested review from genlu and a team December 3, 2024 22:14
@CyrusNajmabadi
Copy link
Member Author

@genlu ptal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CS4033 creates invalid code on partial methods
4 participants