Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary ApiCompat CP0001 errors when type forwards used #31271

Closed
steveharter opened this issue Mar 16, 2023 · 4 comments
Closed

Unnecessary ApiCompat CP0001 errors when type forwards used #31271

steveharter opened this issue Mar 16, 2023 · 4 comments

Comments

@steveharter
Copy link
Member

See dotnet/runtime#82453 (comment) for more detail.

Local errors for when the https://github.com/dotnet/runtime/tree/main/src/libraries/System.DirectoryServices/src/CompatibilitySuppressions.xml file is removed (please delete that file when this issue is fixed):

C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error : API compatibility errors between 'lib/net6.0/System.DirectoryServices.dll' (C:\Users\sharter\.nuget\packages\
system.directoryservices\7.0.0\system.directoryservices.7.0.0.nupkg) and 'lib/net6.0/System.DirectoryServices.dll' (C:\git\runtime1\artifacts\packages\Debug\Shipping\System.DirectoryServices.8.0.0-dev.nupkg): [C:\git\runtime1\src\libraries\System.DirectoryServices\src\
System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermission' exists on [Baseline] lib/net6.0/System.Dire
ctoryServices.dll but not on lib/net6.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAccess' exists on [Baseline] lib/net6.0/Syste
m.DirectoryServices.dll but not on lib/net6.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAttribute' exists on [Baseline] lib/net6.0/Sy
stem.DirectoryServices.dll but not on lib/net6.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntry' exists on [Baseline] lib/net6.0/System
.DirectoryServices.dll but not on lib/net6.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntryCollection' exists on [Baseline] lib/net
6.0/System.DirectoryServices.dll but not on lib/net6.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error : API compatibility errors between 'lib/net7.0/System.DirectoryServices.dll' (C:\Users\sharter\.nuget\packages\
system.directoryservices\7.0.0\system.directoryservices.7.0.0.nupkg) and 'lib/net7.0/System.DirectoryServices.dll' (C:\git\runtime1\artifacts\packages\Debug\Shipping\System.DirectoryServices.8.0.0-dev.nupkg): [C:\git\runtime1\src\libraries\System.DirectoryServices\src\
System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermission' exists on [Baseline] lib/net7.0/System.Dire
ctoryServices.dll but not on lib/net7.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAccess' exists on [Baseline] lib/net7.0/Syste
m.DirectoryServices.dll but not on lib/net7.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAttribute' exists on [Baseline] lib/net7.0/Sy
stem.DirectoryServices.dll but not on lib/net7.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntry' exists on [Baseline] lib/net7.0/System
.DirectoryServices.dll but not on lib/net7.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntryCollection' exists on [Baseline] lib/net
7.0/System.DirectoryServices.dll but not on lib/net7.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error : API compatibility errors between 'lib/netstandard2.0/System.DirectoryServices.dll' (C:\Users\sharter\.nuget\p
ackages\system.directoryservices\7.0.0\system.directoryservices.7.0.0.nupkg) and 'lib/netstandard2.0/System.DirectoryServices.dll' (C:\git\runtime1\artifacts\packages\Debug\Shipping\System.DirectoryServices.8.0.0-dev.nupkg): [C:\git\runtime1\src\libraries\System.Direct
oryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermission' exists on [Baseline] lib/netstandard2.0/Sys
tem.DirectoryServices.dll but not on lib/netstandard2.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAccess' exists on [Baseline] lib/netstandard2
.0/System.DirectoryServices.dll but not on lib/netstandard2.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAttribute' exists on [Baseline] lib/netstanda
rd2.0/System.DirectoryServices.dll but not on lib/netstandard2.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntry' exists on [Baseline] lib/netstandard2.
0/System.DirectoryServices.dll but not on lib/netstandard2.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntryCollection' exists on [Baseline] lib/net
standard2.0/System.DirectoryServices.dll but not on lib/netstandard2.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
@ghost ghost added the untriaged Request triage from a team member label Mar 16, 2023
@ghost
Copy link

ghost commented Mar 16, 2023

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Issue Details

See dotnet/runtime#82453 (comment) for more detail.

Local errors for when the https://github.com/dotnet/runtime/tree/main/src/libraries/System.DirectoryServices/src/CompatibilitySuppressions.xml file is removed (please delete that file when this issue is fixed):

C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error : API compatibility errors between 'lib/net6.0/System.DirectoryServices.dll' (C:\Users\sharter\.nuget\packages\
system.directoryservices\7.0.0\system.directoryservices.7.0.0.nupkg) and 'lib/net6.0/System.DirectoryServices.dll' (C:\git\runtime1\artifacts\packages\Debug\Shipping\System.DirectoryServices.8.0.0-dev.nupkg): [C:\git\runtime1\src\libraries\System.DirectoryServices\src\
System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermission' exists on [Baseline] lib/net6.0/System.Dire
ctoryServices.dll but not on lib/net6.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAccess' exists on [Baseline] lib/net6.0/Syste
m.DirectoryServices.dll but not on lib/net6.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAttribute' exists on [Baseline] lib/net6.0/Sy
stem.DirectoryServices.dll but not on lib/net6.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntry' exists on [Baseline] lib/net6.0/System
.DirectoryServices.dll but not on lib/net6.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntryCollection' exists on [Baseline] lib/net
6.0/System.DirectoryServices.dll but not on lib/net6.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error : API compatibility errors between 'lib/net7.0/System.DirectoryServices.dll' (C:\Users\sharter\.nuget\packages\
system.directoryservices\7.0.0\system.directoryservices.7.0.0.nupkg) and 'lib/net7.0/System.DirectoryServices.dll' (C:\git\runtime1\artifacts\packages\Debug\Shipping\System.DirectoryServices.8.0.0-dev.nupkg): [C:\git\runtime1\src\libraries\System.DirectoryServices\src\
System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermission' exists on [Baseline] lib/net7.0/System.Dire
ctoryServices.dll but not on lib/net7.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAccess' exists on [Baseline] lib/net7.0/Syste
m.DirectoryServices.dll but not on lib/net7.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAttribute' exists on [Baseline] lib/net7.0/Sy
stem.DirectoryServices.dll but not on lib/net7.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntry' exists on [Baseline] lib/net7.0/System
.DirectoryServices.dll but not on lib/net7.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntryCollection' exists on [Baseline] lib/net
7.0/System.DirectoryServices.dll but not on lib/net7.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error : API compatibility errors between 'lib/netstandard2.0/System.DirectoryServices.dll' (C:\Users\sharter\.nuget\p
ackages\system.directoryservices\7.0.0\system.directoryservices.7.0.0.nupkg) and 'lib/netstandard2.0/System.DirectoryServices.dll' (C:\git\runtime1\artifacts\packages\Debug\Shipping\System.DirectoryServices.8.0.0-dev.nupkg): [C:\git\runtime1\src\libraries\System.Direct
oryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermission' exists on [Baseline] lib/netstandard2.0/Sys
tem.DirectoryServices.dll but not on lib/netstandard2.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAccess' exists on [Baseline] lib/netstandard2
.0/System.DirectoryServices.dll but not on lib/netstandard2.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionAttribute' exists on [Baseline] lib/netstanda
rd2.0/System.DirectoryServices.dll but not on lib/netstandard2.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntry' exists on [Baseline] lib/netstandard2.
0/System.DirectoryServices.dll but not on lib/netstandard2.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
C:\Users\sharter\.nuget\packages\microsoft.dotnet.apicompat.task\8.0.100-preview.2.23107.1\build\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error CP0001: Type 'System.DirectoryServices.DirectoryServicesPermissionEntryCollection' exists on [Baseline] lib/net
standard2.0/System.DirectoryServices.dll but not on lib/netstandard2.0/System.DirectoryServices.dll [C:\git\runtime1\src\libraries\System.DirectoryServices\src\System.DirectoryServices.csproj]
Author: steveharter
Assignees: -
Labels:

bug, area-Infrastructure-libraries

Milestone: -

@ericstj
Copy link
Member

ericstj commented Mar 16, 2023

This happens because on the baseline comparison APICompat doesn't resolve any references.

// In order to enable reference support for baseline suppression we need a better way
// to resolve references for the baseline package. Let's not enable it for now.
string[] aggregatedReferences = metadataInformation.Where(m => m.References != null).SelectMany(m => m.References!).Distinct().ToArray();
resolvedExternallyProvidedAssemblyReferences = !options.IsBaselineComparison && aggregatedReferences.Length > 0;

This is done today because we don't go and restore the baseline package for all of it's frameworks to get those references (including ones from targeting pack, etc). While that might be "most correct" I don't think it's work that's worth the effort.

The way I previously discussed making this work was using the right-hand-side references for the left-hand-side baseline so long as we have them. This should work since those references need to be transitively compatible with the left-hand-side and we're not interested in validating compatibility of left-hand-side assemblies that are only part of the references and not assemblies under test.

@ViktorHofer ViktorHofer transferred this issue from dotnet/runtime Mar 17, 2023
@ghost
Copy link

ghost commented Mar 17, 2023

@dotnet/area-infrastructure-libraries a new issue has been filed in the ApiCompat area, please triage

@ViktorHofer ViktorHofer removed the untriaged Request triage from a team member label Mar 17, 2023
@ViktorHofer ViktorHofer added this to the Backlog milestone May 3, 2023
@ViktorHofer
Copy link
Member

Closed by #32930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants