Skip to content

BUG: CC0118 - Unnecessary '.ToString()' call in string concatenation #866

Closed
@kindermannhubert

Description

@kindermannhubert

It is little bit more complicated while concatenating 'tostringed' objects only.

Example:

class C
{
    string M() => 1 + 2.ToString();
}

CC0118 is detected and code after fix looks like this:

class C
{
    string M() => 1 + 2;
}

which is incorrect.

Solution 1: Do not detect CC0118 in such situations.
Solution 2: Fix needs to be smarter.

This is problematic primarily when using solution-wide fix because of possibly large number of wrong fixes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions