Skip to content

Commit 6d702bb

Browse files
committed
Merge branch 'v1.x' into collection-element-conventions
Conflicts: src/FluentNHibernate/Conventions/Instances/ICollectionInstance.cs src/FluentNHibernate/MappingModel/Collections/ElementMapping.cs
2 parents ecef140 + 3c15235 commit 6d702bb

File tree

103 files changed

+1064
-747
lines changed

Some content is hidden

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

103 files changed

+1064
-747
lines changed

src/FluentNHibernate.Testing/ConventionsTests/ApplyingToModel/ArrayConventionTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,12 @@ public void ShouldSetWhereProperty()
167167

168168
#region Helpers
169169

170+
#pragma warning disable 612,618
170171
private void Convention(Action<IArrayInstance> convention)
171172
{
172173
model.Conventions.Add(new ArrayConventionBuilder().Always(convention));
173174
}
175+
#pragma warning restore 612,618
174176

175177
private void VerifyModel(Action<CollectionMapping> modelVerification)
176178
{

src/FluentNHibernate.Testing/ConventionsTests/Inspection/CollectionInspectorMapsToCollectionMapping.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace FluentNHibernate.Testing.ConventionsTests.Inspection
1111
public class CollectionInspectorMapsToCollectionMapping
1212
{
1313
private CollectionMapping mapping;
14-
private IMapInspector inspector;
14+
private ICollectionInspector inspector;
1515

1616
[SetUp]
1717
public void CreateDsl()
@@ -88,7 +88,7 @@ public void SortByIsNotSet()
8888

8989
#region Helpers
9090

91-
private Member Prop(Expression<Func<IMapInspector, object>> propertyExpression)
91+
static Member Prop(Expression<Func<ICollectionInspector, object>> propertyExpression)
9292
{
9393
return ReflectionHelper.GetMember(propertyExpression);
9494
}

src/FluentNHibernate.Testing/ConventionsTests/OverridingFluentInterface/ArrayConventionTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,12 @@ public void WhereShouldntBeOverwritten()
195195

196196
#region Helpers
197197

198+
#pragma warning disable 612,618
198199
private void Convention(Action<IArrayInstance> convention)
199200
{
200201
model.Conventions.Add(new ArrayConventionBuilder().Always(convention));
201202
}
203+
#pragma warning restore 612,618
202204

203205
private void Mapping(Action<OneToManyPart<ExampleClass>> mappingDefinition)
204206
{

src/FluentNHibernate.Testing/ConventionsTests/RunnableConventionsTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ public void ShouldApplyIHibernateMappingConvention()
444444

445445
#region conventions
446446

447+
#pragma warning disable 612,618
447448
private class ArrayConvention : IArrayConvention
448449
{
449450
public void Apply(IArrayInstance instance)
@@ -633,6 +634,8 @@ public void Apply(IHibernateMappingInstance instance)
633634
}
634635
}
635636

637+
#pragma warning restore 612,618
638+
636639
private class OtherObjectUserType : IUserType
637640
{
638641
public new bool Equals(object x, object y)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
using System.Collections.Generic;
2+
using FluentNHibernate.Mapping;
3+
using FluentNHibernate.Utils;
4+
using NUnit.Framework;
5+
6+
namespace FluentNHibernate.Testing.DomainModel
7+
{
8+
[TestFixture]
9+
public class MemberAccessResolverTests
10+
{
11+
[Test]
12+
public void AutoProperty()
13+
{
14+
MemberAccessResolver.Resolve(ReflectionExtensions.ToMember<Example, string>(x => x.AutoProperty))
15+
.ShouldEqual(FluentNHibernate.Mapping.Access.Property);
16+
}
17+
18+
[Test]
19+
public void AutoPropertyPrivateSetter()
20+
{
21+
MemberAccessResolver.Resolve(ReflectionExtensions.ToMember<Example, string>(x => x.AutoPropertyPrivateSetter))
22+
.ShouldEqual(FluentNHibernate.Mapping.Access.BackField);
23+
}
24+
25+
[Test]
26+
public void Property()
27+
{
28+
MemberAccessResolver.Resolve(ReflectionExtensions.ToMember<Example, string>(x => x.Property))
29+
.ShouldEqual(FluentNHibernate.Mapping.Access.Property);
30+
}
31+
32+
[Test]
33+
public void PropertyPrivateSetter()
34+
{
35+
MemberAccessResolver.Resolve(ReflectionExtensions.ToMember<Example, string>(x => x.PropertyPrivateSetter))
36+
.ShouldEqual(FluentNHibernate.Mapping.Access.ReadOnlyPropertyThroughCamelCaseField());
37+
}
38+
39+
[Test]
40+
public void PropertyNoSetter()
41+
{
42+
MemberAccessResolver.Resolve(ReflectionExtensions.ToMember<Example, string>(x => x.PropertyNoSetter))
43+
.ShouldEqual(FluentNHibernate.Mapping.Access.ReadOnlyPropertyThroughCamelCaseField());
44+
}
45+
46+
[Test]
47+
public void Field()
48+
{
49+
MemberAccessResolver.Resolve(ReflectionExtensions.ToMember<Example, string>(x => x.Field))
50+
.ShouldEqual(FluentNHibernate.Mapping.Access.Field);
51+
}
52+
53+
[Test]
54+
public void Method()
55+
{
56+
MemberAccessResolver.Resolve(ReflectionExtensions.ToMember<Example, IEnumerable<Example>>(x => x.GetViaMethod()))
57+
.ShouldEqual(FluentNHibernate.Mapping.Access.Field);
58+
}
59+
60+
#pragma warning disable 649
61+
class Example
62+
{
63+
string property;
64+
string propertyPrivateSetter;
65+
string propertyNoSetter;
66+
67+
public string Field;
68+
IEnumerable<Example> viaMethod;
69+
70+
public string AutoProperty { get; set; }
71+
public string AutoPropertyPrivateSetter { get; private set; }
72+
73+
public string Property
74+
{
75+
get { return property; }
76+
set { property = value; }
77+
}
78+
79+
public string PropertyPrivateSetter
80+
{
81+
get { return propertyPrivateSetter; }
82+
private set { propertyPrivateSetter = value; }
83+
}
84+
85+
public string PropertyNoSetter
86+
{
87+
get { return propertyNoSetter; }
88+
}
89+
90+
public IEnumerable<Example> GetViaMethod()
91+
{
92+
return viaMethod;
93+
}
94+
}
95+
#pragma warning restore 649
96+
}
97+
}
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using FluentNHibernate.Utils.Reflection;
4+
using NUnit.Framework;
5+
6+
namespace FluentNHibernate.Testing.DomainModel
7+
{
8+
[TestFixture]
9+
public class MemberBackingFieldTests
10+
{
11+
[Test]
12+
public void PropertyWithCamelCaseField()
13+
{
14+
var member = ReflectionHelper.GetMember<Example, string>(x => x.PropertyWithCamelCaseField);
15+
Member field;
16+
17+
member.TryGetBackingField(out field);
18+
19+
field.IsField.ShouldBeTrue();
20+
field.Name.ShouldEqual("propertyWithCamelCaseField");
21+
}
22+
23+
[Test]
24+
public void PropertyWithLowerCaseField()
25+
{
26+
var member = ReflectionHelper.GetMember<Example, string>(x => x.PropertyWithLowerCaseField);
27+
Member field;
28+
29+
member.TryGetBackingField(out field);
30+
31+
field.IsField.ShouldBeTrue();
32+
field.Name.ShouldEqual("propertywithlowercasefield");
33+
}
34+
35+
[Test]
36+
public void PropertyWithUnderscoreCamelCaseField()
37+
{
38+
var member = ReflectionHelper.GetMember<Example, string>(x => x.PropertyWithUnderscoreCamelCaseField);
39+
Member field;
40+
41+
member.TryGetBackingField(out field);
42+
43+
field.IsField.ShouldBeTrue();
44+
field.Name.ShouldEqual("_propertyWithUnderscoreCamelCaseField");
45+
}
46+
47+
[Test]
48+
public void PropertyWithUnderscorePascalCaseField()
49+
{
50+
var member = ReflectionHelper.GetMember<Example, string>(x => x.PropertyWithUnderscorePascalCaseField);
51+
Member field;
52+
53+
member.TryGetBackingField(out field);
54+
55+
field.IsField.ShouldBeTrue();
56+
field.Name.ShouldEqual("_PropertyWithUnderscorePascalCaseField");
57+
}
58+
59+
[Test]
60+
public void MethodWithCamelCaseBackingField()
61+
{
62+
var member = ReflectionHelper.GetMember<Example, IEnumerable<Example>>(x => x.CamelCaseMethod());
63+
Member field;
64+
65+
member.TryGetBackingField(out field);
66+
67+
field.IsField.ShouldBeTrue();
68+
field.Name.ShouldEqual("camelCaseMethod");
69+
}
70+
71+
[Test]
72+
public void MethodWithLowerCaseBackingField()
73+
{
74+
var member = ReflectionHelper.GetMember<Example, IEnumerable<Example>>(x => x.LowerCaseMethod());
75+
Member field;
76+
77+
member.TryGetBackingField(out field);
78+
79+
field.IsField.ShouldBeTrue();
80+
field.Name.ShouldEqual("lowercasemethod");
81+
}
82+
83+
[Test]
84+
public void MethodWithUnderscorePascalCaseBackingField()
85+
{
86+
var member = ReflectionHelper.GetMember<Example, IEnumerable<Example>>(x => x.UnderscorePascalCaseMethod());
87+
Member field;
88+
89+
member.TryGetBackingField(out field);
90+
91+
field.IsField.ShouldBeTrue();
92+
field.Name.ShouldEqual("_UnderscorePascalCaseMethod");
93+
}
94+
95+
[Test]
96+
public void GetMethodWithCamelCaseBackingField()
97+
{
98+
var member = ReflectionHelper.GetMember<Example, IEnumerable<Example>>(x => x.GetCamelCaseMethod());
99+
Member field;
100+
101+
member.TryGetBackingField(out field);
102+
103+
field.IsField.ShouldBeTrue();
104+
field.Name.ShouldEqual("camelCaseMethod");
105+
}
106+
107+
[Test]
108+
public void GetMethodWithLowerCaseBackingField()
109+
{
110+
var member = ReflectionHelper.GetMember<Example, IEnumerable<Example>>(x => x.GetLowerCaseMethod());
111+
Member field;
112+
113+
member.TryGetBackingField(out field);
114+
115+
field.IsField.ShouldBeTrue();
116+
field.Name.ShouldEqual("lowercasemethod");
117+
}
118+
119+
[Test]
120+
public void GetMethodWithUnderscorePascalCaseBackingField()
121+
{
122+
var member = ReflectionHelper.GetMember<Example, IEnumerable<Example>>(x => x.GetUnderscorePascalCaseMethod());
123+
Member field;
124+
125+
member.TryGetBackingField(out field);
126+
127+
field.IsField.ShouldBeTrue();
128+
field.Name.ShouldEqual("_UnderscorePascalCaseMethod");
129+
}
130+
131+
#pragma warning disable 649
132+
class Example
133+
{
134+
string propertyWithCamelCaseField;
135+
string _propertyWithUnderscoreCamelCaseField;
136+
string _PropertyWithUnderscorePascalCaseField;
137+
string propertywithlowercasefield;
138+
IEnumerable<Example> camelCaseMethod;
139+
IEnumerable<Example> lowercasemethod;
140+
IEnumerable<Example> _UnderscorePascalCaseMethod;
141+
142+
public string PropertyWithCamelCaseField
143+
{
144+
get { return propertyWithCamelCaseField; }
145+
}
146+
147+
public string PropertyWithLowerCaseField
148+
{
149+
get { return propertywithlowercasefield; }
150+
}
151+
152+
public string PropertyWithUnderscoreCamelCaseField
153+
{
154+
get { return _propertyWithUnderscoreCamelCaseField; }
155+
}
156+
157+
public string PropertyWithUnderscorePascalCaseField
158+
{
159+
get { return _PropertyWithUnderscorePascalCaseField; }
160+
}
161+
162+
public IEnumerable<Example> CamelCaseMethod()
163+
{
164+
return camelCaseMethod;
165+
}
166+
167+
public IEnumerable<Example> LowerCaseMethod()
168+
{
169+
return lowercasemethod;
170+
}
171+
172+
public IEnumerable<Example> UnderscorePascalCaseMethod()
173+
{
174+
return _UnderscorePascalCaseMethod;
175+
}
176+
177+
public IEnumerable<Example> GetCamelCaseMethod()
178+
{
179+
return camelCaseMethod;
180+
}
181+
182+
public IEnumerable<Example> GetLowerCaseMethod()
183+
{
184+
return lowercasemethod;
185+
}
186+
187+
public IEnumerable<Example> GetUnderscorePascalCaseMethod()
188+
{
189+
return _UnderscorePascalCaseMethod;
190+
}
191+
}
192+
#pragma warning restore 649
193+
}
194+
}

0 commit comments

Comments
 (0)