Skip to content

WTG3014 bad code-fix #217

@yaakov-h

Description

@yaakov-h
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions