Skip to content

Commit cc3fab9

Browse files
committed
Remove compatibility clases
1 parent db29d32 commit cc3fab9

33 files changed

+99
-212
lines changed

src/NHibernate.Test/Linq/CustomQueryModelRewriterTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Linq;
44
using System.Linq.Expressions;
55
using System.Text;
6-
using NHibernate.Linq;
76
using NHibernate.Linq.Visitors;
87
using NUnit.Framework;
98
using Remotion.Linq;
@@ -48,7 +47,7 @@ public override void VisitWhereClause(WhereClause whereClause, QueryModel queryM
4847
whereClause.TransformExpressions(new Visitor().Visit);
4948
}
5049

51-
private class Visitor : ExpressionTreeVisitor
50+
private class Visitor : RelinqExpressionVisitor
5251
{
5352
protected override Expression VisitBinary(BinaryExpression expression)
5453
{

src/NHibernate/Linq/ExpressionTreeVisitor.cs

Lines changed: 0 additions & 112 deletions
This file was deleted.
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
using System.Linq.Expressions;
2-
using Remotion.Linq.Clauses.Expressions;
3-
using Remotion.Linq.Parsing;
42

53
namespace NHibernate.Linq.Expressions
64
{
7-
public abstract class NhAggregatedExpression : ExtensionExpression
5+
public abstract class NhAggregatedExpression : Expression
86
{
9-
public Expression Expression { get; set; }
10-
11-
protected NhAggregatedExpression(Expression expression, NhExpressionType type)
12-
: base(expression.Type, (ExpressionType)type)
7+
protected NhAggregatedExpression(Expression expression, NhExpressionType nodeType)
8+
: this(expression, expression.Type, nodeType)
139
{
14-
Expression = expression;
1510
}
1611

17-
protected NhAggregatedExpression(Expression expression, System.Type expressionType, NhExpressionType type)
18-
: base(expressionType, (ExpressionType)type)
12+
protected NhAggregatedExpression(Expression expression, System.Type type, NhExpressionType nodeType)
1913
{
2014
Expression = expression;
15+
NodeType = (ExpressionType) nodeType;
16+
Type = type;
2117
}
2218

19+
public override ExpressionType NodeType { get; }
20+
21+
public override System.Type Type { get; }
22+
23+
public Expression Expression { get; }
24+
2325
protected override Expression VisitChildren(ExpressionVisitor visitor)
2426
{
2527
var newExpression = visitor.Visit(Expression);
2628

2729
return newExpression != Expression
28-
? CreateNew(newExpression)
29-
: this;
30+
? CreateNew(newExpression)
31+
: this;
3032
}
3133

3234
public abstract Expression CreateNew(Expression expression);
3335
}
34-
}
36+
}
Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,32 @@
11
using System.Collections.Generic;
22
using System.Collections.ObjectModel;
33
using System.Linq.Expressions;
4-
using Remotion.Linq.Clauses.Expressions;
5-
using Remotion.Linq.Parsing;
64

75
namespace NHibernate.Linq.Expressions
86
{
9-
public class NhNewExpression : ExtensionExpression
7+
public class NhNewExpression : Expression
108
{
11-
private readonly ReadOnlyCollection<string> _members;
12-
private readonly ReadOnlyCollection<Expression> _arguments;
13-
149
public NhNewExpression(IList<string> members, IList<Expression> arguments)
15-
: base(typeof(object), (ExpressionType)NhExpressionType.New)
16-
{
17-
_members = new ReadOnlyCollection<string>(members);
18-
_arguments = new ReadOnlyCollection<Expression>(arguments);
19-
}
20-
21-
public ReadOnlyCollection<Expression> Arguments
22-
{
23-
get { return _arguments; }
24-
}
25-
26-
public ReadOnlyCollection<string> Members
2710
{
28-
get { return _members; }
11+
Members = new ReadOnlyCollection<string>(members);
12+
Arguments = new ReadOnlyCollection<Expression>(arguments);
2913
}
3014

31-
protected override Expression VisitChildren(ExpressionVisitor visitor)
32-
{
33-
var arguments = visitor.VisitAndConvert(Arguments, "VisitNhNew");
15+
public override System.Type Type => typeof(object);
3416

35-
return arguments != Arguments
36-
? new NhNewExpression(Members, arguments)
37-
: this;
38-
}
39-
}
17+
public override ExpressionType NodeType => (ExpressionType) NhExpressionType.New;
4018

41-
public class NhStarExpression : ExtensionExpression
42-
{
43-
public NhStarExpression(Expression expression)
44-
: base(expression.Type, (ExpressionType)NhExpressionType.Star)
45-
{
46-
Expression = expression;
47-
}
19+
public ReadOnlyCollection<Expression> Arguments { get; }
4820

49-
public Expression Expression
50-
{
51-
get;
52-
private set;
53-
}
21+
public ReadOnlyCollection<string> Members { get; }
5422

5523
protected override Expression VisitChildren(ExpressionVisitor visitor)
5624
{
57-
var newExpression = visitor.Visit(Expression);
25+
var arguments = visitor.VisitAndConvert(Arguments, "VisitNhNew");
5826

59-
return newExpression != Expression
60-
? new NhStarExpression(newExpression)
61-
: this;
27+
return arguments != Arguments
28+
? new NhNewExpression(Members, arguments)
29+
: this;
6230
}
6331
}
64-
}
32+
}
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
using System.Linq.Expressions;
2-
using Remotion.Linq.Clauses.Expressions;
3-
using Remotion.Linq.Parsing;
42

53
namespace NHibernate.Linq.Expressions
64
{
75
/// <summary>
8-
/// Represents an expression that has been nominated for direct inclusion in the SELECT clause.
9-
/// This bypasses the standard nomination process and assumes that the expression can be converted
10-
/// directly to SQL.
6+
/// Represents an expression that has been nominated for direct inclusion in the SELECT clause.
7+
/// This bypasses the standard nomination process and assumes that the expression can be converted
8+
/// directly to SQL.
119
/// </summary>
1210
/// <remarks>
13-
/// Used in the nomination of GroupBy key expressions to ensure that matching select clauses
14-
/// are generated the same way.
11+
/// Used in the nomination of GroupBy key expressions to ensure that matching select clauses
12+
/// are generated the same way.
1513
/// </remarks>
16-
internal class NhNominatedExpression : ExtensionExpression
14+
internal class NhNominatedExpression : Expression
1715
{
18-
public Expression Expression { get; private set; }
19-
20-
public NhNominatedExpression(Expression expression) : base(expression.Type, (ExpressionType)NhExpressionType.Nominator)
16+
public NhNominatedExpression(Expression expression)
2117
{
2218
Expression = expression;
2319
}
2420

21+
public override ExpressionType NodeType => (ExpressionType) NhExpressionType.Nominator;
22+
23+
public override System.Type Type => Expression.Type;
24+
25+
public Expression Expression { get; }
26+
2527
protected override Expression VisitChildren(ExpressionVisitor visitor)
2628
{
2729
var newExpression = visitor.Visit(Expression);
@@ -31,4 +33,4 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
3133
: this;
3234
}
3335
}
34-
}
36+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Linq.Expressions;
2+
3+
namespace NHibernate.Linq.Expressions
4+
{
5+
public class NhStarExpression : Expression
6+
{
7+
public NhStarExpression(Expression expression)
8+
{
9+
Expression = expression;
10+
}
11+
12+
public Expression Expression { get; }
13+
14+
public override ExpressionType NodeType => (ExpressionType) NhExpressionType.Star;
15+
16+
public override System.Type Type => Expression.Type;
17+
18+
protected override Expression VisitChildren(ExpressionVisitor visitor)
19+
{
20+
var newExpression = visitor.Visit(Expression);
21+
22+
return newExpression != Expression
23+
? new NhStarExpression(newExpression)
24+
: this;
25+
}
26+
}
27+
}

src/NHibernate/Linq/GroupBy/GroupBySelectClauseRewriter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
using Remotion.Linq.Clauses;
77
using Remotion.Linq.Clauses.Expressions;
88
using Remotion.Linq.Clauses.ResultOperators;
9+
using Remotion.Linq.Parsing;
910
using Remotion.Linq.Parsing.ExpressionVisitors;
1011

1112
namespace NHibernate.Linq.GroupBy
1213
{
1314
//This should be renamed. It handles entire querymodels, not just select clauses
14-
internal class GroupBySelectClauseRewriter : ExpressionTreeVisitor
15+
internal class GroupBySelectClauseRewriter : RelinqExpressionVisitor
1516
{
1617
public static Expression ReWrite(Expression expression, GroupResultOperator groupBy, QueryModel model)
1718
{

src/NHibernate/Linq/GroupBy/GroupKeyNominator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace NHibernate.Linq.GroupBy
1212
/// This class nominates sub-expression trees on the GroupBy Key expression
1313
/// for inclusion in the Select clause.
1414
/// </summary>
15-
internal class GroupKeyNominator : ExpressionTreeVisitor
15+
internal class GroupKeyNominator : RelinqExpressionVisitor
1616
{
1717
private GroupKeyNominator() { }
1818

src/NHibernate/Linq/GroupBy/KeySelectorVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace NHibernate.Linq.GroupBy
66
{
7-
internal class KeySelectorVisitor : ExpressionTreeVisitor
7+
internal class KeySelectorVisitor : RelinqExpressionVisitor
88
{
99
private readonly GroupResultOperator _groupBy;
1010

src/NHibernate/Linq/GroupJoin/GroupJoinSelectClauseRewriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace NHibernate.Linq.GroupJoin
99
{
10-
public class GroupJoinSelectClauseRewriter : ExpressionTreeVisitor
10+
public class GroupJoinSelectClauseRewriter : RelinqExpressionVisitor
1111
{
1212
private readonly IsAggregatingResults _results;
1313

src/NHibernate/Linq/GroupJoin/LocateGroupJoinQuerySource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace NHibernate.Linq.GroupJoin
77
{
8-
public class LocateGroupJoinQuerySource : ExpressionTreeVisitor
8+
public class LocateGroupJoinQuerySource : RelinqExpressionVisitor
99
{
1010
private readonly IsAggregatingResults _results;
1111
private GroupJoinClause _groupJoin;

src/NHibernate/Linq/GroupJoin/NonAggregatingGroupJoinRewriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private IsAggregatingResults GetGroupJoinInformation(IEnumerable<GroupJoinClause
154154

155155
}
156156

157-
internal class QuerySourceUsageLocator : ExpressionTreeVisitor
157+
internal class QuerySourceUsageLocator : RelinqExpressionVisitor
158158
{
159159
private readonly IQuerySource _querySource;
160160
private bool _references;

0 commit comments

Comments
 (0)