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

WTG3104 bad code-fix #217

Open
yaakov-h opened this issue Nov 27, 2023 · 0 comments
Open

WTG3104 bad code-fix #217

yaakov-h opened this issue Nov 27, 2023 · 0 comments
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
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

1 participant