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

Code cleanup & modernization #31077

Merged
merged 1 commit into from
Jun 14, 2023
Merged

Code cleanup & modernization #31077

merged 1 commit into from
Jun 14, 2023

Conversation

roji
Copy link
Member

@roji roji commented Jun 13, 2023

Mostly automated code fixes, especially to apply C# pattern matching.

@roji roji merged commit 58e2473 into dotnet:main Jun 14, 2023
@roji roji deleted the Cleanup branch June 14, 2023 08:47
e => e.GetDeclaredNavigations().Any(n => !n.IsOnDependent && !n.ForeignKey.IsOwnership)))
e => e.GetDeclaredNavigations().Any(n => n is { IsOnDependent: false, ForeignKey.IsOwnership: false })))
Copy link
Contributor

Choose a reason for hiding this comment

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

Now see, this is why I hate most of these. It was perfectly terse and clear before.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do find the pattern here better - my brain automatically understands that we're checking two things on n, rather than two unrelated conditions (with n being repeated).

But I agree that this is an edge case, do you really hate most of the changes in this PR? IMHO it cuts down on so much crap and makes conditions so much easier to grok... If people hate it we can revert.

Copy link
Contributor

@bricelam bricelam Jun 14, 2023

Choose a reason for hiding this comment

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

It’s half and half for me. I’m fine doing the occasional bulk cleanup like this. I just put a lot of thought into how I express conditions that it’s sad to see them occasionally mangled in the name of simplification or new language features.

Copy link
Member Author

Choose a reason for hiding this comment

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

I probably should have asked/cleared this with the team before doing it - my bad.

We should maybe briefly discuss on Friday - we can also decide to roll at least some of it back, and/or not have this corrected/suggested automatically, but rather decide on a one-by-one basis - though looking at this PR, my personal take is that 95% of these make total sense and do improve code quality.

Copy link
Member

Choose a reason for hiding this comment

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

This adds a few additional null checks if n and ForeignKey are reference types, could be a reason to not use pattern matching in some cases.

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