APICompat does not catch inconsistent return types of overidden member in multi-targeting library
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Describe the bug
If I change the return type a normal non-virtual method, APICompat will catch this and raise a diagnostic. Even if the new return type is covariant.
If instead the method is virtual and overridden with different return types using https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/covariant-returns we will not flag the difference.
This creates a problem when another derived type exists in an assembly which doesn't multi-target in the same way.
### To Reproduce
See https://github.com/ericstj/sample-code/tree/covariantReturn
The application will throw a TypeLoadException when run, but apicompat against the library does not catch this.
### Exceptions (if any)
TypeLoadException.
### Further technical details
It looks to me like the metadata for covariant returns marks the derived type as `new`. I can reproduce a similar bug without covariant returns feature if I make the derived method `new virtual` and then override that in the `netstandard` library. APICompat will not flag this and it will cause a runtime error since the most-derived member (in the netstandard library) will return a non-covariant type with the more specific base assembly.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.