dotnet/roslyn

diagnostic for override in Interface should suggest using explicit interface implementation instead

オープン

#39,940 opened on 2019/11/21

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

Repository metrics

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

説明

Version Used: VS 16.4 preview 4

Steps to Reproduce:

The following code fails to compile:

public interface I {
    abstract void M();
}

public interface I1 : I {
    override void M() {}
}

public class C : I1 {}

The correct code should be:

public interface I {
    abstract void M();
}

public interface I1 : I {
    void I.M() {}
}

public class C : I1 {}

However it's not immediately obvious that's the case, and there's nothing pointing you to use explicit interface implementation instead.

Expected Behavior:

DIagnostic should be:

error CS0106: The modifier 'override' is not valid for this item. Use explicit interface implementation void I.M instead.

Ideally there should also be a code fix for this.

Actual Behavior:

error CS0106: The modifier 'override' is not valid for this item

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