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

Allow a user to generate operators when generating .Equals #17976

Merged
merged 4 commits into from
Mar 21, 2017

Conversation

CyrusNajmabadi
Copy link
Member

No description provided.

@CyrusNajmabadi
Copy link
Member Author

Feature looks like

image

And generates code like:

image

@CyrusNajmabadi
Copy link
Member Author

Tagging @dotnet/roslyn-ide

Note: this is a followup PR to #17975. When that PR goes through, this PR will becomea lot smaller.

@Pilchie
Copy link
Member

Pilchie commented Mar 20, 2017

Not a full review, but when generating operator == need to check order1 for null if it's a reference type.

@Pilchie
Copy link
Member

Pilchie commented Mar 20, 2017

(or call the static object.Equals() though that add a lot of indirection (and boxing in value type cases)

@CyrusNajmabadi
Copy link
Member Author

Not a full review, but when generating operator == need to check order1 for null if it's a reference type.

We do, if the type is a reference type. We don't when it's a value type :)

@CyrusNajmabadi
Copy link
Member Author

CyrusNajmabadi commented Mar 20, 2017

In the reference case we call EqualityComparer<T>.Default.Equals(...), thus getting null checks, without any boxing or typechecks.

@CyrusNajmabadi
Copy link
Member Author

Preemptively merging in. Let me know if there's anything you want me to change.

@CyrusNajmabadi CyrusNajmabadi merged commit 1cac31c into dotnet:master Mar 21, 2017
@CyrusNajmabadi CyrusNajmabadi deleted the generateEqualsOptions branch March 21, 2017 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants