dotnet / dotnet/sdk

Microsoft.DotNet.ApiCompat.Tool CP0001 mis-fires across target frameworks when type is replaced with type forwarder

Open
#50,672 1 comment 0 reactions 0 assignees View on GitHub
Area-ApiCompat
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Describe the bug

When a type is declared for netstandard2.0 and replaced with a type forwarder in netstandard2.1, CP0001 claims we have an API compatibility error between the two dll's.

### To Reproduce

```cs
#if NETSTANDARD2_0
public class System.Buffers.SequenceReader(ReadOnlySequence sequence) { }
#else
[assembly: TypeForwardedTo(typeof(System.Buffers.SequenceReader<>))]
#endif
```

Expected: No errors (assuming the forwarded to `SequenceReader` is in fact API compatible with the original ns2.0 declaration)

Actual:

```
CP0001: Type 'System.Buffers.SequenceReader' exists on lib/netstandard2.0/Nerdbank.Streams.dll but not on lib/netstandard2.1/Nerdbank.Streams.dll
```

### Further technical details

microsoft.dotnet.apicompat.tool 9.0.304

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the CP0001 report with the conditional C# example and microsoft.dotnet.apicompat.tool 9.0.304. Read the Microsoft.DotNet.ApiCompat.Tool handling for type declarations and type forwarders across target frameworks. Done means the netstandard2.0 declaration and netstandard2.1 forwarder are treated as compatible when the forwarded type is API compatible.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.