Skip to content

Comparing symbols using only one set of references can result in false differences due inconsistent compare strings #46834

Closed
@ericstj

Description

@ericstj

Describe the bug

When APICompat is comparing libraries from different frameworks and only has one set of references, and those references differ on CoreLib, APICompat may generate identifiers that are not consistent

To Reproduce

Discovered in dotnet/wcf#5742 (comment)

While debugging I noticed the comparsion strings for the two sides differ:

System.Nullable<System.Int32> System.ServiceModel.Federation.WSTrustTokenParameters.KeySize.get
System.Int32? System.ServiceModel.Federation.WSTrustTokenParameters.KeySize.get

Roslyn has enough to resolve that System.Nullable<System.Int32> should be System.Int32? but it is not.

It seems like this is due to the fact that in this case, the left symbol references Nullable in System.Runtime 8.0 - but right hand side has System.Runtime in netstandard. The right hand side references do contain a facade for System.Runtime that can forward the type to netstandard, but roslyn doesn't appear to be resolving this. It could be due to the version mismatch (netstandard's System.Runtime is version 4.1.2.0).

It's pretty unusual to do this type of comparison where a package replaces a framework specific asset (net8.0) with a more generic asset (netstandard2.0) and in general this comparison is not compatible from a consumption side of things (consuming net8.0 in netstandard2.0) but it is compatible from a production perspective.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions