CA1067 on C# record implementing a VB.NET interface
- Dominant language
- No language data
- Stars
- 1.9k
- Forks
- 173
- Avg merge
- 10d 13h
- Merged PRs (30d)
- 1
Description
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 `latest-recommended` in my projects
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.