dotnet/roslyn

Unclear CS0252 (Possible unintended reference comparison)

Offen

#58.996 geöffnet am 21.01.2022

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

Repository-Metriken

Stars
 (20.414 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

Version Used:

17.1.0 P1.1

Steps to Reproduce:

using System;

public class C
{
    public void M(Action x, Action y)
    {
        _ = (MulticastDelegate)x == y;
    }
}

Expected Behavior:

Either no warning, or a more clear warning.

Actual Behavior:

warning CS0252: Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'MulticastDelegate'

Contributor Guide