Open
Description
Describe the bug
When a public class implements a public generic interface but the generic type argument provided is internal a CP0008 validation error is raised when we make changes on the internal type.
I don't think the error should be raised as I can see no way how this could be binary or source incompatible.
To Reproduce
- Create nuget package with version
1.0.0
with the following codepublic class MyClass : IMyInterface<Foo> { } public interface IMyInterface<T> { } internal record Foo;
- Enable package validation for the package in the csproj
<PropertyGroup> <!-- ... --> <EnablePackageValidation>true</EnablePackageValidation> <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion> </PropertyGroup>
- Rename the internal (!) record
Foo
toBar
so that there is now the following codepublic class MyClass : IMyInterface<Bar> { } public interface IMyInterface<T> { } internal record Bar;
- Increment the package version to
1.1.0
and rundotnet pack
Actual Result
The following error occurs:
Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): Error : API compatibility errors between 'lib/net6.0/AdventureWorks.Client.dll' (C:\Users\bitbonk\.nuget\packages\adventureworks.client\1.0.0\adventureworks.client.1.0.0.nupkg) and 'lib/net6.0/AdventureWorks.Client.dll' (C:\source\AdventureWorks.Client\AdventureWorks.Client\bin\Debug\AdventureWorks.Client.1.1.0.nupkg):
Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): Error CP0008 : Type 'A.MyClass' does not implement interface 'A.IMyInterface<A.Foo>' on lib/net6.0/AdventureWorks.Client.dll but it does on [Baseline] lib/net6.0/AdventureWorks.Client.dll
Expected Result
No error occurs.