Skip to content

Commit 0909592

Browse files
committed
NH-3944 - Upgrade to ReLinq 2.1.1
1 parent 800203a commit 0909592

File tree

84 files changed

+1171
-720
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1171
-720
lines changed

src/NHibernate.DomainModel/NHibernate.DomainModel.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
<Folder Include="Properties\" />
303303
</ItemGroup>
304304
<ItemGroup>
305+
<None Include="app.config" />
305306
<None Include="packages.config" />
306307
</ItemGroup>
307308
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

src/NHibernate.DomainModel/app.config

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<runtime>
4+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5+
<dependentAssembly>
6+
<assemblyIdentity name="Remotion.Linq" publicKeyToken="fee00910d6e5f53b" culture="neutral" />
7+
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
8+
</dependentAssembly>
9+
</assemblyBinding>
10+
</runtime>
11+
</configuration>

src/NHibernate.Test/App.config

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33

44
<configSections>
@@ -15,6 +15,10 @@
1515
<!-- Required by ReflectHelperFixture.TypeFoundInNotLoadedAssembly test -->
1616
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" applies-to="v2.0.50727">
1717
<qualifyAssembly partialName="System.Web" fullName="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
18+
<dependentAssembly>
19+
<assemblyIdentity name="Remotion.Linq" publicKeyToken="fee00910d6e5f53b" culture="neutral" />
20+
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
21+
</dependentAssembly>
1822
</assemblyBinding>
1923
</runtime>
2024

@@ -66,7 +70,7 @@
6670
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" />
6771
</layout>
6872
</appender>
69-
<appender name="rollingFile" type="log4net.Appender.RollingFileAppender, log4net" >
73+
<appender name="rollingFile" type="log4net.Appender.RollingFileAppender, log4net">
7074
<param name="File" value="log.txt" />
7175
<param name="AppendToFile" value="false" />
7276
<param name="RollingStyle" value="Date" />
@@ -98,12 +102,12 @@
98102

99103
</log4net>
100104

101-
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup>
105+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /></startup>
102106
<runtime>
103107
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
104108
<dependentAssembly>
105-
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral"/>
106-
<bindingRedirect oldVersion="0.0.0.0-2.6.1.12217" newVersion="2.6.1.12217"/>
109+
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
110+
<bindingRedirect oldVersion="0.0.0.0-2.6.1.12217" newVersion="2.6.1.12217" />
107111
</dependentAssembly>
108112
</assemblyBinding>
109113
</runtime>

src/NHibernate.Test/Linq/CustomQueryModelRewriterTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ public QueryModelVisitorBase CreateVisitor(VisitorParameters parameters)
4040
}
4141
}
4242

43-
public class CustomVisitor : QueryModelVisitorBase
43+
public class CustomVisitor : NhQueryModelVisitorBase
4444
{
4545
public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index)
4646
{
47-
whereClause.TransformExpressions(new Visitor().VisitExpression);
47+
whereClause.TransformExpressions(new Visitor().Visit);
4848
}
4949

50-
private class Visitor : ExpressionTreeVisitor
50+
private class Visitor : RelinqExpressionVisitor
5151
{
52-
protected override Expression VisitBinaryExpression(BinaryExpression expression)
52+
protected override Expression VisitBinary(BinaryExpression expression)
5353
{
5454
if (
5555
expression.NodeType == ExpressionType.Equal ||
@@ -82,7 +82,7 @@ protected override Expression VisitBinaryExpression(BinaryExpression expression)
8282
}
8383
}
8484

85-
return base.VisitBinaryExpression(expression);
85+
return base.VisitBinary(expression);
8686
}
8787
}
8888
}

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@
8383
<HintPath>..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll</HintPath>
8484
<Private>True</Private>
8585
</Reference>
86+
<Reference Include="Remotion.Linq, Version=2.1.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
87+
<HintPath>..\packages\Remotion.Linq.2.1.1\lib\net45\Remotion.Linq.dll</HintPath>
88+
<Private>True</Private>
89+
</Reference>
8690
<Reference Include="System" />
91+
<Reference Include="System.ComponentModel.Composition" />
8792
<Reference Include="System.configuration" />
8893
<Reference Include="System.Core">
8994
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -100,9 +105,6 @@
100105
<Reference Include="System.Xml.Linq">
101106
<RequiredTargetFramework>3.5</RequiredTargetFramework>
102107
</Reference>
103-
<Reference Include="Remotion.Linq, Version=1.15.15.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
104-
<HintPath>..\packages\Remotion.Linq.1.15.15.0\lib\portable-net45+wp80+wpa81+win\Remotion.Linq.dll</HintPath>
105-
</Reference>
106108
</ItemGroup>
107109
<ItemGroup>
108110
<Compile Include="..\SharedAssemblyInfo.cs">
@@ -2787,9 +2789,7 @@
27872789
<EmbeddedResource Include="ReadOnly\TextHolder.hbm.xml" />
27882790
<EmbeddedResource Include="ReadOnly\VersionedNode.hbm.xml" />
27892791
<EmbeddedResource Include="NHSpecificTest\NH2554\Mappings.hbm.xml" />
2790-
<None Include="packages.config">
2791-
<SubType>Designer</SubType>
2792-
</None>
2792+
<None Include="packages.config" />
27932793
</ItemGroup>
27942794
<ItemGroup>
27952795
<ProjectReference Include="..\NHibernate.DomainModel\NHibernate.DomainModel.csproj">

src/NHibernate.Test/packages.config

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
<package id="Iesi.Collections" version="4.0.1.4000" targetFramework="net461" />
55
<package id="log4net" version="2.0.7" targetFramework="net461" />
66
<package id="NUnit" version="3.6.0" targetFramework="net461" />
7-
<package id="Remotion.Linq" version="1.15.15.0" targetFramework="net461" />
7+
<package id="Remotion.Linq" version="2.1.1" targetFramework="net461" />
8+
<package id="System.Collections" version="4.0.11" targetFramework="net461" />
9+
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net461" />
10+
<package id="System.Linq" version="4.1.0" targetFramework="net461" />
811
<package id="System.Linq.Dynamic" version="1.0.7" targetFramework="net461" />
12+
<package id="System.Linq.Expressions" version="4.1.0" targetFramework="net461" />
13+
<package id="System.Linq.Queryable" version="4.0.1" targetFramework="net461" />
14+
<package id="System.ObjectModel" version="4.0.12" targetFramework="net461" />
15+
<package id="System.Reflection" version="4.1.0" targetFramework="net461" />
16+
<package id="System.Reflection.Extensions" version="4.0.1" targetFramework="net461" />
17+
<package id="System.Runtime" version="4.1.0" targetFramework="net461" />
18+
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net461" />
19+
<package id="System.Threading" version="4.0.11" targetFramework="net461" />
920
</packages>
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<configSections>
4-
<section name="hibernate-configuration"
5-
type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
4+
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
65
</configSections>
76

87
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
@@ -13,4 +12,13 @@
1312
</property>
1413
</session-factory>
1514
</hibernate-configuration>
16-
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
15+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /></startup>
16+
<runtime>
17+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
18+
<dependentAssembly>
19+
<assemblyIdentity name="Remotion.Linq" publicKeyToken="fee00910d6e5f53b" culture="neutral" />
20+
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
21+
</dependentAssembly>
22+
</assemblyBinding>
23+
</runtime>
24+
</configuration>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using Remotion.Linq;
3+
4+
namespace NHibernate.Linq.Clauses
5+
{
6+
public abstract class NhClauseBase
7+
{
8+
/// <summary>
9+
/// Accepts the specified visitor.
10+
/// </summary>
11+
/// <param name="visitor">The visitor to accept.</param>
12+
/// <param name="queryModel">The query model in whose context this clause is visited.</param>
13+
/// <param name="index">
14+
/// The index of this clause in the <paramref name="queryModel" />'s
15+
/// <see cref="P:Remotion.Linq.QueryModel.BodyClauses" /> collection.
16+
/// </param>
17+
public void Accept(IQueryModelVisitor visitor, QueryModel queryModel, int index)
18+
{
19+
if (visitor == null) throw new ArgumentNullException(nameof(visitor));
20+
if (queryModel == null) throw new ArgumentNullException(nameof(queryModel));
21+
if (!(visitor is INhQueryModelVisitor nhVisitor))
22+
throw new ArgumentException("Expect visitor to implement INhQueryModelVisitor", nameof(visitor));
23+
24+
Accept(nhVisitor, queryModel, index);
25+
}
26+
27+
protected abstract void Accept(INhQueryModelVisitor visitor, QueryModel queryModel, int index);
28+
}
29+
}
Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,78 @@
1-
using Remotion.Linq.Clauses;
2-
using Remotion.Linq.Clauses.ExpressionTreeVisitors;
1+
using System;
32
using System.Linq.Expressions;
3+
using Remotion.Linq;
4+
using Remotion.Linq.Clauses;
45

56
namespace NHibernate.Linq.Clauses
67
{
7-
public class NhHavingClause : WhereClause
8+
public class NhHavingClause : NhClauseBase, IBodyClause
89
{
9-
public NhHavingClause(Expression predicate)
10-
: base(predicate)
10+
Expression _predicate;
11+
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="T:NhHavingClause" /> class.
14+
/// </summary>
15+
/// <param name="predicate">The predicate used to filter data items.</param>
16+
public NhHavingClause(Expression predicate)
17+
{
18+
if (predicate == null) throw new ArgumentNullException(nameof(predicate));
19+
_predicate = predicate;
20+
}
21+
22+
/// <summary>
23+
/// Gets the predicate, the expression representing the where condition by which the data items are filtered
24+
/// </summary>
25+
public Expression Predicate
26+
{
27+
get { return _predicate; }
28+
set
29+
{
30+
if (value == null) throw new ArgumentNullException(nameof(value));
31+
_predicate = value;
32+
}
33+
}
34+
35+
protected override void Accept(INhQueryModelVisitor visitor, QueryModel queryModel, int index)
1136
{
37+
visitor.VisitNhHavingClause(this, queryModel, index);
38+
}
39+
40+
/// <inheritdoc />
41+
IBodyClause IBodyClause.Clone(CloneContext cloneContext)
42+
{
43+
return Clone(cloneContext);
44+
}
45+
46+
/// <summary>
47+
/// Transforms all the expressions in this clause and its child objects via the given
48+
/// <paramref name="transformation" /> delegate.
49+
/// </summary>
50+
/// <param name="transformation">
51+
/// The transformation object. This delegate is called for each <see cref="T:System.Linq.Expressions.Expression" />
52+
/// within this
53+
/// clause, and those expressions will be replaced with what the delegate returns.
54+
/// </param>
55+
public void TransformExpressions(Func<Expression, Expression> transformation)
56+
{
57+
if (transformation == null) throw new ArgumentNullException(nameof(transformation));
58+
Predicate = transformation(Predicate);
1259
}
1360

1461
public override string ToString()
1562
{
16-
return "having " + FormattingExpressionTreeVisitor.Format(Predicate);
63+
return "having " + Predicate;
64+
}
65+
66+
/// <summary>Clones this clause.</summary>
67+
/// <param name="cloneContext">
68+
/// The clones of all query source clauses are registered with this
69+
/// <see cref="T:Remotion.Linq.Clauses.CloneContext" />.
70+
/// </param>
71+
/// <returns></returns>
72+
public NhHavingClause Clone(CloneContext cloneContext)
73+
{
74+
if (cloneContext == null) throw new ArgumentNullException(nameof(cloneContext));
75+
return new NhHavingClause(Predicate);
1776
}
1877
}
19-
}
78+
}

0 commit comments

Comments
 (0)