Skip to content

Commit a96e826

Browse files
committed
EntityWithUserTypeCanHaveLinqGenerators: Fix R# warnings and various minor cleanup.
1 parent 588ff1a commit a96e826

File tree

8 files changed

+27
-42
lines changed

8 files changed

+27
-42
lines changed

src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/EntityWithUserTypeProperty.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System.Collections.Generic;
2-
using System.Linq;
3-
using System.Text;
4-
using NHibernate.Mapping.ByCode;
5-
using NHibernate.Mapping.ByCode.Conformist;
6-
1+

72
namespace NHibernate.Test.NHSpecificTest.EntityWithUserTypeCanHaveLinqGenerators
83
{
94
public class EntityWithUserTypeProperty

src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/EntityWithUserTypePropertyGeneratorsRegistry.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ namespace NHibernate.Test.NHSpecificTest.EntityWithUserTypeCanHaveLinqGenerators
55
{
66
public class EntityWithUserTypePropertyGeneratorsRegistry : DefaultLinqToHqlGeneratorsRegistry
77
{
8-
public EntityWithUserTypePropertyGeneratorsRegistry() : base()
8+
public EntityWithUserTypePropertyGeneratorsRegistry()
99
{
1010
RegisterGenerator(ReflectionHelper.GetMethod((IExample e) => e.IsEquivalentTo(null)),
11-
new EntityWithUserTypePropertyIsEquivelentGenerator());
11+
new EntityWithUserTypePropertyIsEquivalentGenerator());
1212
}
1313
}
14-
}
14+
}
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,27 @@
99

1010
namespace NHibernate.Test.NHSpecificTest.EntityWithUserTypeCanHaveLinqGenerators
1111
{
12-
public class EntityWithUserTypePropertyIsEquivelentGenerator : BaseHqlGeneratorForMethod
12+
public class EntityWithUserTypePropertyIsEquivalentGenerator : BaseHqlGeneratorForMethod
1313
{
14-
public EntityWithUserTypePropertyIsEquivelentGenerator() : base()
14+
public EntityWithUserTypePropertyIsEquivalentGenerator()
1515
{
16-
SupportedMethods = new[] { ReflectionHelper.GetMethodDefinition((IExample e) => e.IsEquivalentTo(null)) };
16+
SupportedMethods = new[] {ReflectionHelper.GetMethodDefinition((IExample e) => e.IsEquivalentTo(null))};
1717
}
18-
public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
18+
19+
public override HqlTreeNode BuildHql(
20+
MethodInfo method,
21+
Expression targetObject,
22+
ReadOnlyCollection<Expression> arguments,
23+
HqlTreeBuilder treeBuilder,
24+
IHqlExpressionVisitor visitor)
1925
{
2026
var left = treeBuilder.Cast(visitor.Visit(targetObject).AsExpression(), typeof(string));
21-
var right = treeBuilder.Cast(visitor.Visit(arguments.Cast<Expression>().First()).AsExpression(),
22-
typeof(string));
23-
24-
27+
var right = treeBuilder.Cast(visitor.Visit(arguments.First()).AsExpression(), typeof(string));
2528

2629
var leftSubstring = treeBuilder.MethodCall("substring", left, treeBuilder.Constant(4));
2730
var rightSubstring = treeBuilder.MethodCall("substring", right, treeBuilder.Constant(4));
2831
var equals = treeBuilder.Equality(leftSubstring, rightSubstring);
2932
return equals;
3033
}
3134
}
32-
}
35+
}

src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/ExampleUserType.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Data;
4-
using System.Text;
53
using NHibernate.SqlTypes;
64
using NHibernate.UserTypes;
75

@@ -54,7 +52,7 @@ public object Disassemble(object value)
5452
return value;
5553
}
5654

57-
public SqlType[] SqlTypes { get { return new[] { SqlTypeFactory.GetString(255) }; } }
55+
public SqlType[] SqlTypes { get { return new SqlType[] { SqlTypeFactory.GetString(255) }; } }
5856

5957
public System.Type ReturnedType { get { return typeof(IExample); } }
6058
public bool IsMutable { get { return true; } }

src/NHibernate.Test/NHSpecificTest/EntityWithUserTypeCanHaveLinqGenerators/Fixture.cs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
using System;
2-
using System.Collections;
1+
using System.Collections;
32
using System.Linq;
43
using NHibernate.Cfg;
5-
using NHibernate.Dialect;
64
using NHibernate.Linq;
7-
using NHibernate.Mapping.ByCode;
8-
using NHibernate.Test.NHSpecificTest.FileStreamSql2008;
95
using NUnit.Framework;
106

117

@@ -25,16 +21,10 @@ protected override string MappingsAssembly
2521
get { return "NHibernate.Test"; }
2622
}
2723

28-
protected override bool AppliesTo(Dialect.Dialect dialect)
24+
protected override void Configure(Configuration configuration)
2925
{
30-
return true;
31-
}
32-
33-
protected override void Configure(Configuration cfg)
34-
{
35-
36-
base.Configure(cfg);
37-
cfg.LinqToHqlGeneratorsRegistry<EntityWithUserTypePropertyGeneratorsRegistry>();
26+
base.Configure(configuration);
27+
configuration.LinqToHqlGeneratorsRegistry<EntityWithUserTypePropertyGeneratorsRegistry>();
3828
}
3929

4030
protected override void OnSetUp()
@@ -111,8 +101,9 @@ public void LinqMethodWorksForUserType()
111101
Assert.AreEqual(2, entities.Count);
112102
}
113103
}
104+
114105
[Test]
115-
public void CanQueryWithHQL()
106+
public void CanQueryWithHql()
116107
{
117108
using (var session = OpenSession())
118109
using (session.BeginTransaction())
@@ -126,4 +117,4 @@ public void CanQueryWithHQL()
126117
}
127118
}
128119
}
129-
}
120+
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
using System;
21

32
namespace NHibernate.Test.NHSpecificTest.EntityWithUserTypeCanHaveLinqGenerators
43
{
5-
64
public interface IExample
75
{
86
string Value { get; set; }
97
bool IsEquivalentTo(IExample that);
108
}
11-
}
9+
}

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@
725725
<Compile Include="Component\Basic\ComponentWithUniqueConstraintTests.cs" />
726726
<Compile Include="NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\BarExample.cs" />
727727
<Compile Include="NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\EntityWithUserTypeProperty.cs" />
728-
<Compile Include="NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\EntityWithUserTypePropertyIsEquivelentGenerator.cs" />
728+
<Compile Include="NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\EntityWithUserTypePropertyIsEquivalentGenerator.cs" />
729729
<Compile Include="NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\EntityWithUserTypePropertyGeneratorsRegistry.cs" />
730730
<Compile Include="NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\ExampleUserType.cs" />
731731
<Compile Include="NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\Fixture.cs" />

src/NHibernate/Linq/Visitors/ExpressionParameterVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ private static bool IsNullObject(ConstantExpression expression)
119119
return expression.Type == typeof(Object) && expression.Value == null;
120120
}
121121
}
122-
}
122+
}

0 commit comments

Comments
 (0)