Skip to content

[GenAPI] Give generated attributes a reliable order#5572

Merged
dougbu merged 2 commits intomasterfrom
dougbu/compare.invariant
May 28, 2020
Merged

[GenAPI] Give generated attributes a reliable order#5572
dougbu merged 2 commits intomasterfrom
dougbu/compare.invariant

Conversation

@dougbu
Copy link
Contributor

@dougbu dougbu commented May 27, 2020

  • current situation results in inconsistent orders as the CI agent varies

- current situation results in inconsistent orders as the CI agent varies
@dougbu dougbu requested review from ericstj and safern May 27, 2020 21:35
@dougbu
Copy link
Contributor Author

dougbu commented May 27, 2020

@riarenas @markwilkie is there a way to test this change in and test using it in an aspnetcore branch? The variance is blocking my work in dotnet/aspnetcore#22017.

I could turn off ref/ code gen in our build verification but am loath to increase our engineering debt in that way. Much prefer to know a real fix is coming and that it works.

Note I can't reproduce the problem locally. Found this broken line by inspection.

@markwilkie
Copy link
Member

Yea. Once this is checked in, you could branch asp and grab arcade from the validate channel...

@dougbu
Copy link
Contributor Author

dougbu commented May 27, 2020

Thanks @markwilkie

I can't think of a potential downside and am hoping @ericstj and @safern agree.

public virtual int Compare(T x, T y)
{
return string.Compare(GetKey(x), GetKey(y));
return string.Compare(GetKey(x), GetKey(y), StringComparison.OrdinalIgnoreCase);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why IgnoreCase? That seems to be a behavior change. It also breaks the comparer contract since GetHashCode would return different values for values that differ only in case (and thus would be treated equal).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have been fine w/ Ordinal but worried that would be inconsistent with

securityAttributes = securityAttributes.OrderBy(s => s.Action.ToString(), StringComparer.OrdinalIgnoreCase);
Looking deeper, I was confused: That line is comparing SecurityAction values (an enum) and not entire attribute keys. (Might still be a bug nearby because I'm not sure ISecurityAttribute.Attributes is sorted at all. LMK if that's not a concern for some reason.)

For this line, Ordinal it is…

@dougbu
Copy link
Contributor Author

dougbu commented May 28, 2020

/ping reviewers

(Looks like this is going to pass PR validation.)

@dougbu dougbu merged commit fc3b1e6 into master May 28, 2020
@dougbu dougbu deleted the dougbu/compare.invariant branch May 28, 2020 02:10
Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants