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

[API Compat] AttributeDifference is reported when same attribute appears multiple times with different ctor args #7585

Open
safern opened this issue Jul 1, 2021 · 0 comments
Labels
area-Infrastructure-libraries Area maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etc help wanted

Comments

@safern
Copy link
Member

safern commented Jul 1, 2021

Take the following values:

Left:

[UnsupportedOS("browser")]
public class Foo
{
}

Right:

[UnsupportedOS("browser")]
[UnsupportedOS("ios")]
public class Foo
{
}

We would get an error:

error : CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Net.Http.HttpClientHandler.Send(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)' changed from '[UnsupportedOSPlatformAttribute("browser")]' in the contract to '[UnsupportedOSPlatformAttribute("browser")]' in the implementation.

There should be no error here.

The problem seems to be as we group attributes by constructor documentation ID, and then when comparing the groups, we noticed the right group has 2 entries and the left 1, and thus it is marked as changed:

var attrGroups = attributes.GroupBy(c => c.Constructor.DocId());

And we always use the first attribute on the group for the error string:

string contractKey = attributeComparer.GetKey(group[0].Attributes.First());
string implementationKey = attributeComparer.GetKey(group[1].Attributes.First());

cc: @ericstj @steveisok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Infrastructure-libraries Area maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etc help wanted
Projects
None yet
Development

No branches or pull requests

4 participants