Roslyn-analyzers: Possibly incorrect CA1067

Created on 21 Jan 2019  路  3Comments  路  Source: dotnet/roslyn-analyzers

Analyzer package

Microsoft.CodeAnalysis.FxCopAnalyzers

Package Version

v2.6.3

Diagnostic ID

CA1067

Repro steps

using System;

public class A<T> : IEquatable<T>
    where T : A<T>
{
    public virtual bool Equals(T other) => false;

    public override bool Equals(object obj) => Equals(obj as T);
}

public class B : A<B>
{
}

Expected behavior

No code analysis warnings are produced for class B.

Actual behavior

The definition of class B is annotated with warning CA1067 "Type B should override Equals because it implements IEquatable".

Notes

If I recall correctly, v2.6.2 didn't exhibit this behavior.

4 - In Review Area-Microsoft.CodeQuality.Analyzers Bug

All 3 comments

Any news?

In my opinition possible cause of this issue is fix of #1914.

@pantosha That seems correct. Would you like to contribute a PR to fix it?

Manish, thank you very much for this one, looking forward to new release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OmarTawfik picture OmarTawfik  路  3Comments

SixFive7 picture SixFive7  路  4Comments

sharwell picture sharwell  路  4Comments

paulomorgado picture paulomorgado  路  3Comments

paulomorgado picture paulomorgado  路  3Comments