-
Notifications
You must be signed in to change notification settings - Fork 70
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 switching from params to non-params overload in xUnit1051 #192
Conversation
@dotnet-policy-service agree |
If the analyzer has fired on a `params` method, it means that the new overload is actually array + `CancellationToken`, since C# forbids placing any argument after a params argument. To avoid generating invalid code, we need to replace the params expression with an array creation expression. Does not currently handle the expanded range of allowed `params` types implemented in C# 13. Considering you can use _any_ type that implements `IEnumerable<T>`, I think it would be quite difficult to handle all the different cases there. Being a new feature, it's also less likely to be used, though this will of course change over time... Closes [#3068](xunit/xunit#3068)
98b8731
to
a559757
Compare
It looks like there are some trivial test failures to be fixed. Normally I would fix these, but your branch is not open for me to contribute to. 😄 |
Oops! That should hopefully be fixed now. Thanks for letting me know. It's odd you can't commit to my branch, that setting appears to be enabled 😕 edit: on the whitespace issue, I've noticed it's because the raw string literals use spaces for indentation but the rest of the code uses tabs. I've used tabs in my raw string literals, would you prefer these be switched to spaces? |
I've tended to use spaces, because the way the fixers work by default in testing is the they appear to use the default settings (i.e., 4 spaces), so matching that default makes the results much more predictable. Unfortunately, it's not easy to switch between tabs and spaces when editing the multi-line literal strings, which means I'm wearing out my spacebar. 😂 |
Makes sense. For consistency's sake I've adapted the new tests to do the same. Sorry you keep having to approve the workflows! I assume the 4 space issue appears when a code fix adds a new line? Maybe you could fix it by passing an |
I don't think I knew you could do this. 😂 I might do this and then fix everything to use tabs! Thanks! |
Thanks! |
If the analyzer has fired on a
params
method, it means that the new overload is actually array +CancellationToken
, since C# forbids placing any argument after a params argument. To avoid generating invalid code, we need to replace the params expression with an array creation expression.Does not currently handle the expanded range of allowed
params
types implemented in C# 13. Considering you can use any type that implementsIEnumerable<T>
, I think it would be quite difficult to handle all the different cases there. Being a new feature, it's also less likely to be used, though this will of course change over time...Closes #3068