-
Notifications
You must be signed in to change notification settings - Fork 466
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
handle params array in the argument list #5082
Conversation
...rosoft.NetCore.Analyzers/Runtime/CSharpForwardCancellationTokenToInvocationsFixer.Visitor.cs
Outdated
Show resolved
Hide resolved
.../UnitTests/Microsoft.NetCore.Analyzers/Runtime/ForwardCancellationTokenToInvocationsTests.cs
Outdated
Show resolved
Hide resolved
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.
Can you also add a test for an API shaped like this:
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. |
Codecov Report
@@ 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 |
@carlossanlop Can you please review this PR? |
Tagging @ryzngard for review |
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.
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...
...etCore.Analyzers/Runtime/CSharpForwardCancellationTokenToInvocationsFixer.TypeNameVisitor.cs
Show resolved
Hide resolved
...etCore.Analyzers/Runtime/CSharpForwardCancellationTokenToInvocationsFixer.TypeNameVisitor.cs
Show resolved
Hide resolved
} | ||
} | ||
|
||
if (symbol.NullableAnnotation() == NullableAnnotation.Annotated && |
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.
Is it possible for symbol.NullableAnnotation()
to return Annotated
for value types?
...zers/Core/Microsoft.NetCore.Analyzers/Runtime/ForwardCancellationTokenToInvocations.Fixer.cs
Outdated
Show resolved
Hide resolved
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 |
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.
nit: you're just digging into through symbol.ElementType
here and above. Can we just combine into a single loop?
...NetCore.Analyzers/Runtime/BasicForwardCancellationTokenToInvocationsFixer.TypeNameVisitor.vb
Outdated
Show resolved
Hide resolved
...NetCore.Analyzers/Runtime/BasicForwardCancellationTokenToInvocationsFixer.TypeNameVisitor.vb
Show resolved
Hide resolved
…/ForwardCancellationTokenToInvocationsTests.cs Co-authored-by: Youssef Victor <youssefvictor00@gmail.com>
…ardCancellationTokenToInvocations.Fixer.cs Co-authored-by: Andrew Hall <ryzngard@live.com>
aaf4736
to
dc448ea
Compare
fixes #4842
TODO: