dotnet/roslyn

Unclear CS0252 (Possible unintended reference comparison)

オープン

#58,996 opened on 2022/01/21

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

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'

コントリビューターガイド