Microsoft.DotNet.ApiCompat.Tool CP0012 mis-fires when replacing `virtual` with `override` across target frameworks
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Describe the bug
A `TextWriter`-derived class declares a method as `virtual` on netstandard2.0 and `override` on netstandard2.1.
The APICompat tool
### To Reproduce
Compile this class in a project that multitargets netstandard2.0 and netstandard2.1:
```cs
class MyWriter : TextWriter
{
#if NETSTANDARD2_1_OR_GREATER
public override void Write(ReadOnlySpan buffer)
#else
public virtual void Write(ReadOnlySpan buffer)
#endif
{ }
}
```
(methods irrelevant to the repro omitted above for brevity.)
Expected: no issues
Actual:
> P0012: Cannot remove virtual keyword from member 'Nerdbank.Streams.BufferTextWriter.Write(System.ReadOnlySpan)'.
Whether a method is declared `virtual` or `override`, the caller's IL is the same (I believe), and therefore switching from one to the other is not a breaking change.
### Further technical details
microsoft.dotnet.apicompat.tool 9.0.304
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.