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

handle params array in the argument list #5082

Conversation

jmarolf
Copy link
Contributor

@jmarolf jmarolf commented May 1, 2021

fixes #4842

TODO:

  • figure out why the SyntaxGenerator for VB generates an invalide tree.,

Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

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

Can you also add a test for an API shaped like this:

https://docs.microsoft.com/en-us/dotnet/api/system.data.entity.dbset.findasync?view=entity-framework-6.2.0

public virtual System.Threading.Tasks.Task<object> FindAsync (params object[] keyValues);
public virtual System.Threading.Tasks.Task<object> FindAsync (System.Threading.CancellationToken cancellationToken, params object[] keyValues);

@jmarolf
Copy link
Contributor Author

jmarolf commented May 3, 2021

Can you also add a test for an API shaped like this:

https://docs.microsoft.com/en-us/dotnet/api/system.data.entity.dbset.findasync?view=entity-framework-6.2.0

public virtual System.Threading.Tasks.Task<object> FindAsync (params object[] keyValues);
public virtual System.Threading.Tasks.Task<object> FindAsync (System.Threading.CancellationToken cancellationToken, params object[] keyValues);

The current analyzer/codefixer was intentionally designed to not consider this. I'll get this PR in and then follow up with a re-write allowing cancellation tokens to be in any position.

@jmarolf jmarolf marked this pull request as ready for review May 3, 2021 22:12
@jmarolf jmarolf requested a review from a team as a code owner May 3, 2021 22:12
@codecov
Copy link

codecov bot commented May 3, 2021

Codecov Report

Merging #5082 (dc448ea) into main (87c20b9) will decrease coverage by 0.10%.
The diff coverage is 38.07%.

@@            Coverage Diff             @@
##             main    #5082      +/-   ##
==========================================
- Coverage   95.60%   95.50%   -0.11%     
==========================================
  Files        1200     1203       +3     
  Lines      276345   276824     +479     
  Branches    16633    16696      +63     
==========================================
+ Hits       264212   264375     +163     
- Misses       9963    10249     +286     
- Partials     2170     2200      +30     

@jmarolf jmarolf requested a review from mavasani May 3, 2021 23:42
@mavasani
Copy link
Contributor

@carlossanlop Can you please review this PR?

@mavasani
Copy link
Contributor

Tagging @ryzngard for review

Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

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

Overall looks good. Minor clarifications and questions about moving some code to SyntaxFacts. Surprised it took this much complicated visitor code to get the correct element type and construct an array...

}
}

if (symbol.NullableAnnotation() == NullableAnnotation.Annotated &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for symbol.NullableAnnotation() to return Annotated for value types?

Comment on lines +34 to +39
While arrayType IsNot Nothing
Dim commaCount = Math.Max(0, arrayType.Rank - 1)
Dim commas = SyntaxFactory.TokenList(Enumerable.Repeat(SyntaxFactory.Token(SyntaxKind.CommaToken), commaCount))
ranks.Add(SyntaxFactory.ArrayRankSpecifier(SyntaxFactory.Token(SyntaxKind.OpenParenToken), commas, SyntaxFactory.Token(SyntaxKind.CloseParenToken)))
arrayType = TryCast(arrayType.ElementType, IArrayTypeSymbol)
End While
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you're just digging into through symbol.ElementType here and above. Can we just combine into a single loop?

@jmarolf jmarolf enabled auto-merge July 17, 2021 03:30
@jmarolf jmarolf force-pushed the bugfix/pass-cancelation-token-with-params-array-overload branch from aaf4736 to dc448ea Compare August 2, 2021 17:35
@jmarolf jmarolf disabled auto-merge August 2, 2021 23:09
@jmarolf jmarolf merged commit c474643 into dotnet:main Aug 2, 2021
@jmarolf jmarolf deleted the bugfix/pass-cancelation-token-with-params-array-overload branch August 2, 2021 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CA2016: Forward cancellation token codefix is incorrect
5 participants