roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

RCS1244 false-positive in statement lambdas

Open jhinder opened this issue 3 years ago • 0 comments
trafficstars

Product and Version Used: Roslynator 4.1.1 in VS 17.3.5

Steps to Reproduce: Apply the codefix for RCS1244 on the default() expression.

var x = () =>
{
    return default(object);
               // ~~~~~~~~ RCS1244: Simplify 'default' expression
};

This affects statement lambdas, but not expression lambdas.

var x = () => default(object); // No diagnostics

Actual Behavior: The argument is removed, leaving a typeless default literal.

var x = () =>
{
    return default;
        // ~~~~~~~ CS8917: There is no target type for the default literal
};

Expected Behavior: The codefix is not offered.

jhinder avatar Sep 29 '22 08:09 jhinder