CA1067 on C# record implementing a VB.NET interface
enrij opened this issue · comments
Hi,
I'm experiencing a curious behavior using dotnet format --verify-no-changes
command and I also managed to reproduce it in a new project from scratch using .NET core 8 (version 8.0.201
).
Take the following C# record
definition as reference
public record MyRecord(string A, string B, long C);
if you create an interface in the same C# project and implement it in the record, dotnet format
works like a charm
public interface IMyInterface
{
string A { get; }
string B { get; }
long C { get; }
}
public record MyRecord(string A, string B, long C) : IMyInterface;`
BUT (🍑)... If the same interface comes from another class library project created using VB.NET
Public Interface IMyInterfaceVB
ReadOnly Property A As String
ReadOnly Property B As String
ReadOnly Property C As Long
End Interface
dotnet format --verify-no-changes
now fails throwing a warning
warning CA1067: Type DotnetFormatCA1067Bug.MyRecord should override Equals because it implements IEquatable
and dotnet format
effectively tries to implement Equals
method on the record
public record MyRecord(string A, string B, long C) : IMyInterfaceVB
{
public override bool Equals(object obj)
{
return Equals(obj as MyRecord);
}
}
Am I missing something? 🤔
For reference:
dotnet build
doesn't raise any warning about CA1067 even using the VB.NET interface- I'm currently using
<AnalysisLevel>latest-recommended</AnalysisLevel>
in my projects