Skip to content

Commit

Permalink
Query: Make IPrintableExpression.Print explicit interface implementation
Browse files Browse the repository at this point in the history
Issue:
- We have Print extension method on Expression without any additional arguments.
- We also have IPrintableExpression.Print method which takes ExpressionPrinter as argument.

So when calling Print on a arbitrary expression, extension method works fine. But when calling print on a custom expression when type is known (especially in debugger), it asks to pass the ExpressionPrinter argument as it does not pick up extension method.
This is a breaking change but unlikely to cause any issues since Print method on custom expression directly should not be called.
  • Loading branch information
smitpatel committed May 27, 2020
1 parent 2402ae4 commit e1c2857
Show file tree
Hide file tree
Showing 63 changed files with 92 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private Expression BindMember(MemberIdentity member, Type entityClrType, bool cl
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/InExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public virtual InExpression Update([NotNull] SqlExpression item, [NotNull] SqlEx
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public virtual KeyAccessExpression Update([NotNull] Expression outerExpression)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public virtual ObjectAccessExpression Update([NotNull] Expression outerExpressio
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public virtual ObjectArrayProjectionExpression Update(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/OrderingExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public virtual OrderingExpression Update([NotNull] SqlExpression expression)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public virtual ProjectionExpression Update([NotNull] Expression expression)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/SqlBinaryExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public virtual SqlBinaryExpression Update([NotNull] SqlExpression left, [NotNull
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public virtual SqlConditionalExpression Update(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/SqlConstantExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
5 changes: 4 additions & 1 deletion src/EFCore.Cosmos/Query/Internal/SqlExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public abstract void Print(ExpressionPrinter expressionPrinter);
protected abstract void Print([NotNull] ExpressionPrinter expressionPrinter);

/// <inheritdoc />
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) => Print(expressionPrinter);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public virtual SqlFunctionExpression Update([NotNull] IReadOnlyList<SqlExpressio
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/SqlUnaryExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public virtual SqlUnaryExpression Update([NotNull] SqlExpression operand)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public virtual EntityShaperExpression BindNavigation([NotNull] INavigation navig
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ EntityProjectionExpression copyEntityProjectionToOuter(EntityProjectionExpressio
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public virtual SingleResultShaperExpression Update([NotNull] Expression projecti
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

base.Print(expressionPrinter);
expressionPrinter.Append($".FromSql({Sql}, ");
expressionPrinter.Visit(Argument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public virtual IRelationalCommand GetRelationalCommand([NotNull] IReadOnlyDictio
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
expressionPrinter.AppendLine("RelationalCommandCache.SelectExpression(");
using (expressionPrinter.Indent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

expressionPrinter.Append(Function.MethodInfo.DisplayName());
expressionPrinter.Append("(");
expressionPrinter.VisitCollection(Arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public virtual RelationalCollectionShaperExpression Update(
}

/// <inheritdoc />
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public virtual CaseExpression Update(
: this;

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public virtual CollateExpression Update([NotNull] SqlExpression operand)
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ColumnExpression MakeNullable()
=> new ColumnExpression(Name, Table, Type.MakeNullable(), TypeMapping, true);

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public virtual CrossApplyExpression Update([NotNull] TableExpressionBase table)
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public virtual CrossJoinExpression Update([NotNull] TableExpressionBase table)
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public virtual ExceptExpression Update([NotNull] SelectExpression source1, [NotN
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public virtual ExistsExpression Update([NotNull] SelectExpression subquery)
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Relational/Query/SqlExpressions/InExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public virtual InExpression Update(
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public virtual InnerJoinExpression Update([NotNull] TableExpressionBase table, [
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public virtual IntersectExpression Update([NotNull] SelectExpression source1, [N
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public virtual LeftJoinExpression Update([NotNull] TableExpressionBase table, [N
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public virtual LikeExpression Update(
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public virtual OrderingExpression Update([NotNull] SqlExpression expression)
}

/// <inheritdoc />
public virtual void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public virtual OuterApplyExpression Update([NotNull] TableExpressionBase table)
}

/// <inheritdoc />
public override void Print(ExpressionPrinter expressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public ProjectionExpression Update([NotNull] SqlExpression expression)
}

/// <inheritdoc />
public void Print(ExpressionPrinter expressionPrinter)
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

Expand Down
Loading

0 comments on commit e1c2857

Please sign in to comment.