Skip to content

Cleanup and refactor extension expressions - #551

Merged
austindrenski merged 1 commit into
npgsql:devfrom
austindrenski:refactor-extension-expressions
Jul 31, 2018
Merged

Cleanup and refactor extension expressions#551
austindrenski merged 1 commit into
npgsql:devfrom
austindrenski:refactor-extension-expressions

Conversation

@austindrenski

@austindrenskiaustindrenski commented Jul 29, 2018

Copy link
Copy Markdown
Contributor

We have several custom expression types that use the ExpressionType.Extension. These can be visited by overriding VisitExtension(...) rather than explicitly dispatching from the Expression.Accept(...) method.

This is partially cosmetic, but it also clarifies where we are (and are not) perturbing the normal behavior of a generic ExpressionVisitor pattern. Further, this also reduces the public API surface of the various expression visitors by moving all of the custom visits from public to protected.

Repurposing this PR to add doc comments and cleanup some inconsistencies in the extension expressions.

Moved from #541.

@roji

roji commented Jul 29, 2018

Copy link
Copy Markdown
Member

I don't have time to write a full review at the moment, but this goes against the pattern used by EF Core expressions, so regardless of what we think about advantages/disadvantages I'm pretty reluctant to accept it. I'm also not sure it's an improvement to have NpgsqlSqlTranslatingExpressionVisitor aware of all our expression types in a new VisitExtension() override.

I'd recommend thinking a bit more about what exact value this brings to the table, which justifies departing from the "standard" expression pattern in EF Core itself.

@austindrenski
austindrenskiforce-pushed the refactor-extension-expressions branch from cc9e9c5 to 656d5c6CompareJuly 29, 2018 20:54
@austindrenski

austindrenski commented Jul 29, 2018

Copy link
Copy Markdown
ContributorAuthor

this goes against the pattern used by EF Core expressions, so regardless of what we think about advantages/disadvantages I'm pretty reluctant to accept it.

Oh yikes. I didn't realize it was following a common pattern....but looking at it again, it clearly is. The value for this PR was purely to unify patterns to what I'm used to seeing in non-EF Expression work (where visits are commonly protected).

I've force-pushed over the previous commit to revert the pattern modifications, while keeping the doc comments/refactors.

The big motivation behind this PR is to unify some of the style and layout in our expression and visitor classes. #541 is getting complex, so my hope is that some style cohesion will make it easier to navigate. (More concerned with consistency than changing the pattern.)

I'm also not sure it's an improvement to have NpgsqlSqlTranslatingExpressionVisitor aware of all our expression types in a new VisitExtension() override.

I guess I was weighing one class knowing of many as being "better" than many knowing of one. But that's entirely opinion and moot given the above.

I'd recommend thinking a bit more about what exact value this brings to the table, which justifies departing from the "standard" expression pattern in EF Core itself.

I'm going to repurpose this PR to add the doc comments and consistency-refactors, without the changes to the visitor pattern.

@austindrenskiaustindrenski changed the title Refactor extension expressions and visitor patternCleanup and refactor extension expressionsJul 29, 2018
@roji

roji commented Jul 29, 2018

Copy link
Copy Markdown
Member

OK, sounds good. Yeah, as a general rule try to look at what's happening in EF Core itself before changing our own classes - we should try to stick to whatever it is they do as long as it makes sense.

Ping me when you want a review on this (or if it's trivial stuff feel free to merge as usual).

@austindrenski
austindrenskiforce-pushed the refactor-extension-expressions branch 2 times, most recently from dd01457 to c037992CompareJuly 29, 2018 21:40
@austindrenski

Copy link
Copy Markdown
ContributorAuthor

@roji All set for another look.

- Add doc comments and refactors for consistency.
@austindrenski
austindrenskiforce-pushed the refactor-extension-expressions branch from c037992 to 2b86ebfCompareJuly 29, 2018 22:30
@austindrenski

Copy link
Copy Markdown
ContributorAuthor

@roji I'm about finished with #541, but I need to merge this before #541 can be reviewed.

At this point, I think this is almost entirely cosmetic. I'm going to go over the diff once more in the morning (UTC−05:00), and then merge it if everything checks out.

If you want me to hold off on the merge so you can give it a more thorough look, just let me know.

@austindrenski
austindrenski merged commit b58dcfb into npgsql:devJul 31, 2018
@austindrenski
austindrenski deleted the refactor-extension-expressions branch July 31, 2018 12:58
@rojiroji added cleanup and removed refactor labels May 29, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@austindrenski@roji