Skip to content

Unnecessary ApiCompat CP0001 errors when type forwards used #31271

Closed

Description

@steveharter

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]

Activity

  1. ghost added
    untriagedRequest triage from a team member
    on Mar 16, 2023
  2. ericstj commented on Mar 16, 2023

    @ericstj
    Member

    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.

  3. transferred this issue fromdotnet/runtimeon Mar 17, 2023
  4. added this to the Backlog milestone on May 3, 2023
  5. ViktorHofer commented on Jun 1, 2023

    @ViktorHofer
    Member

    Closed by #32930

  6. added theissue type on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions