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

WTG3014 bad code-fix #217

Open
yaakov-h opened this issue Nov 27, 2023 · 1 comment
Open

WTG3014 bad code-fix #217

yaakov-h opened this issue Nov 27, 2023 · 1 comment
Labels

Comments

@yaakov-h
Copy link
Member

var expected = new object[] { viewModel }.Concat(viewModel.Items);

This triggers WTG3014: Don't use Concat when prepending a single element to an enumerable.

The code-fix changes it to:

var expected = viewModel.Items.Prepend(viewModel);

However, viewModel and viewModel.Items do not share a common type, so this then causes CS0411: The type arguments for method 'Enumerable.Prepend(IEnumerable, TSource)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

We should probably change this to .Prepend<object> to preserve the explicit typing.

@yaakov-h yaakov-h added the bug label Nov 27, 2023
@brian-reichle
Copy link
Contributor

WTG3104 doesn't exist yet, I assume you mean WTG3014.

@yaakov-h yaakov-h changed the title WTG3104 bad code-fix WTG3014 bad code-fix Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants