Skip to content

Commit 5cef9cf

Browse files
committed
Revert tuplizer changes
1 parent a091e5a commit 5cef9cf

File tree

15 files changed

+28
-147
lines changed

15 files changed

+28
-147
lines changed

src/FluentNHibernate.Testing/DomainModel/Mapping/ComponentPartTester.cs

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using FluentNHibernate.MappingModel;
3-
using NUnit.Framework;
1+
using NUnit.Framework;
42

53
namespace FluentNHibernate.Testing.DomainModel.Mapping;
64

@@ -105,34 +103,6 @@ public void ComponentSetsClass()
105103
.ForMapping(m =>
106104
m.Component(x => x.Component, c => c.Map(x => x.Name)))
107105
.Element("class/component").HasAttribute("class", typeof(ComponentTarget).AssemblyQualifiedName);
108-
}
109-
110-
[Test]
111-
public void ComponentCanSetTuplizer()
112-
{
113-
Type tuplizerType = typeof(NHibernate.Tuple.Entity.PocoEntityTuplizer);
114-
new MappingTester<PropertyTarget>()
115-
.ForMapping(m =>
116-
m.Component(x => x.Component, c => c.Tuplizer(TuplizerMode.Poco, tuplizerType)))
117-
.Element("class/component/tuplizer")
118-
.HasAttribute("class", tuplizerType.AssemblyQualifiedName)
119-
.HasAttribute("entity-mode", nameof(TuplizerMode.Poco).ToLower());
120-
}
121-
122-
[Test]
123-
public void ComponentCanSetTuplizerInCorrectOrderRegardlessOfDeclaration()
124-
{
125-
Type tuplizerType = typeof(NHibernate.Tuple.Entity.PocoEntityTuplizer);
126-
new MappingTester<PropertyTarget>()
127-
.ForMapping(m =>
128-
m.Component(x => x.Component, c =>
129-
{
130-
c.Map(x => x.Name);
131-
c.ParentReference(x => x.MyParent);
132-
c.Tuplizer(TuplizerMode.Poco, tuplizerType);
133-
}))
134-
.Element("class/component/tuplizer").Exists().ShouldBeInParentAtPosition(0)
135-
.Element("class/component/parent").Exists().ShouldBeInParentAtPosition(1)
136-
.Element("class/component/property").Exists().ShouldBeInParentAtPosition(2);
137-
}
106+
}
107+
138108
}

src/FluentNHibernate.Testing/DomainModel/Mapping/MappingTester.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public virtual MappingTester<T> SubClassMapping<TSubClass>(Action<SubclassMap<TS
4848

4949
return this;
5050
}
51-
51+
5252
public virtual MappingTester<T> ForMapping(Action<ClassMap<T>> mappingAction)
5353
{
5454
var classMap = new ClassMap<T>();
@@ -189,9 +189,7 @@ public virtual MappingTester<T> ShouldBeInParentAtPosition(int elementPosition)
189189
else
190190
{
191191
XmlElement elementAtPosition = (XmlElement)currentElement.ParentNode.ChildNodes.Item(elementPosition);
192-
// Assert.That(elementWithoutChildren0, IsEqualTo(elementWithoutChildren1)) always returns true (it defaults
193-
// to the NUnit IEnumerable comparer, which returns equal cause both don't have child nodes).
194-
Assert.That(elementAtPosition?.OuterXml, Is.EqualTo(currentElement.OuterXml), $"Expected '{currentElement.Name}' but was '{elementAtPosition.Name}'");
192+
Assert.That(elementAtPosition, Is.EqualTo(currentElement), $"Expected '{currentElement.Name}' but was '{elementAtPosition.Name}'");
195193
}
196194

197195
return this;

src/FluentNHibernate.Testing/DomainModel/Mapping/SubClassTester.cs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System;
21
using FluentNHibernate.Conventions;
32
using FluentNHibernate.Conventions.Instances;
43
using FluentNHibernate.Mapping;
5-
using FluentNHibernate.MappingModel;
64
using NUnit.Framework;
75

86
namespace FluentNHibernate.Testing.DomainModel.Mapping;
@@ -592,28 +590,7 @@ public void SubSubclassOneToManyReferenceHasConventionApplied()
592590
.HasAttribute("foreign-key", "test_fk");
593591

594592
}
595-
596-
[Test]
597-
public void SubclassCanSetTuplizerInCorrectOrder()
598-
{
599-
Type tuplizerType = typeof(NHibernate.Tuple.Entity.PocoEntityTuplizer);
600-
new MappingTester<MappedObject>()
601-
.SubClassMapping<MappedObjectSubclass>(m =>
602-
{
603-
m.Map(x => x.SubclassProperty);
604-
m.Tuplizer(TuplizerMode.Poco, tuplizerType);
605-
m.DiscriminatorValue("test");
606-
})
607-
.ForMapping(m =>
608-
{
609-
m.DiscriminateSubClassesOnColumn("test_column");
610-
m.Id(x => x.Id);
611-
m.Tuplizer(TuplizerMode.Poco, tuplizerType);
612-
})
613-
.Element("class/subclass/tuplizer").Exists().ShouldBeInParentAtPosition(0)
614-
.Element("class/tuplizer").Exists().ShouldBeInParentAtPosition(0);
615-
}
616-
593+
617594
public class TestPropertyConvention : IPropertyConvention
618595
{
619596
public void Apply(IPropertyInstance instance)

src/FluentNHibernate.Testing/DomainModel/Mapping/UnionSubclassTester.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
using FluentNHibernate.MappingModel;
31
using NUnit.Framework;
42

53
namespace FluentNHibernate.Testing.DomainModel.Mapping;
@@ -46,24 +44,4 @@ public void ShouldAllowEntityNameToBeSetOnUnionSubclasses()
4644
}).Element("class/union-subclass")
4745
.HasAttribute("entity-name", "name");
4846
}
49-
50-
[Test]
51-
public void SubclassCanSetTuplizerInCorrectOrder()
52-
{
53-
Type tuplizerType = typeof(NHibernate.Tuple.Entity.PocoEntityTuplizer);
54-
new MappingTester<MappedObject>()
55-
.SubClassMapping<MappedObjectSubclass>(m =>
56-
{
57-
m.Map(x => x.SubclassProperty);
58-
m.Tuplizer(TuplizerMode.Poco, tuplizerType);
59-
})
60-
.ForMapping(m =>
61-
{
62-
m.UseUnionSubclassForInheritanceMapping();
63-
m.Id(x => x.Id);
64-
m.Tuplizer(TuplizerMode.Poco, tuplizerType);
65-
})
66-
.Element("class/union-subclass/tuplizer").Exists().ShouldBeInParentAtPosition(0)
67-
.Element("class/tuplizer").Exists().ShouldBeInParentAtPosition(0);
68-
}
6947
}

src/FluentNHibernate/Mapping/ClassMap.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,17 @@ public ClassMap<T> ApplyFilter(string name)
583583
/// </summary>
584584
/// <param name="mode">Tuplizer entity-mode</param>
585585
/// <param name="tuplizerType">Tuplizer type</param>
586-
public TuplizerPart Tuplizer(TuplizerMode mode, Type tuplizerType) => CreateTuplizerPart(mode, tuplizerType);
587-
586+
public TuplizerPart Tuplizer(TuplizerMode mode, Type tuplizerType)
587+
{
588+
providers.TuplizerMapping = new TuplizerMapping();
589+
providers.TuplizerMapping.Set(x => x.Mode, Layer.UserSupplied, mode);
590+
providers.TuplizerMapping.Set(x => x.Type, Layer.UserSupplied, new TypeReference(tuplizerType));
591+
592+
return new TuplizerPart(providers.TuplizerMapping)
593+
.Type(tuplizerType)
594+
.Mode(mode);
595+
}
596+
588597
ClassMapping IMappingProvider.GetClassMapping()
589598
{
590599
var mapping = new ClassMapping(attributes.Clone());

src/FluentNHibernate/Mapping/ClasslikeMapBase.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Collections.Generic;
44
using System.Linq.Expressions;
55
using FluentNHibernate.Mapping.Providers;
6-
using FluentNHibernate.MappingModel;
76
using FluentNHibernate.Utils;
87

98
namespace FluentNHibernate.Mapping;
@@ -439,17 +438,6 @@ protected StoredProcedurePart StoredProcedure(string element, string innerText)
439438
providers.StoredProcedures.Add(part);
440439
return part;
441440
}
442-
443-
protected TuplizerPart CreateTuplizerPart(TuplizerMode mode, Type tuplizerType)
444-
{
445-
providers.TuplizerMapping = new TuplizerMapping();
446-
providers.TuplizerMapping.Set(x => x.Mode, Layer.UserSupplied, mode);
447-
providers.TuplizerMapping.Set(x => x.Type, Layer.UserSupplied, new TypeReference(tuplizerType));
448-
449-
return new TuplizerPart(providers.TuplizerMapping)
450-
.Type(tuplizerType)
451-
.Mode(mode);
452-
}
453441

454442
internal IEnumerable<IPropertyMappingProvider> Properties => providers.Properties;
455443

src/FluentNHibernate/Mapping/ComponentPart.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@ public ComponentPart<T> LazyLoad()
4141
nextBool = true;
4242
return this;
4343
}
44-
45-
/// <summary>
46-
/// Configures the tuplizer for this component. The tuplizer defines how to transform
47-
/// a Property-Value to its persistent representation, and viceversa a Column-Value
48-
/// to its in-memory representation, and the EntityMode defines which tuplizer is in use.
49-
/// </summary>
50-
/// <param name="mode">Tuplizer entity-mode</param>
51-
/// <param name="tuplizerType">Tuplizer type</param>
52-
public TuplizerPart Tuplizer(TuplizerMode mode, Type tuplizerType) => CreateTuplizerPart(mode, tuplizerType);
5344

5445
IComponentMapping IComponentMappingProvider.GetComponentMapping()
5546
{

src/FluentNHibernate/Mapping/ComponentPartBase.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ protected ComponentMapping CreateComponentMapping()
166166

167167
if (member is not null)
168168
mapping.Set(x => x.Name, Layer.Defaults, member.Name);
169-
170-
mapping.Set(x => x.Tuplizer, Layer.UserSupplied, providers.TuplizerMapping);
171-
169+
172170
foreach (var property in providers.Properties)
173171
mapping.AddProperty(property.GetPropertyMapping());
174172

src/FluentNHibernate/Mapping/SubClassPart.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using FluentNHibernate.Mapping.Providers;
55
using FluentNHibernate.MappingModel;
66
using FluentNHibernate.MappingModel.ClassBased;
7+
using FluentNHibernate.Utils;
78

89
namespace FluentNHibernate.Mapping;
910

src/FluentNHibernate/Mapping/SubclassMap.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,6 @@ public void Extends(Type type)
277277
{
278278
attributes.Set("Extends", Layer.UserSupplied, type);
279279
}
280-
281-
/// <summary>
282-
/// Configures the tuplizer for this entity. The tuplizer defines how to transform
283-
/// a Property-Value to its persistent representation, and viceversa a Column-Value
284-
/// to its in-memory representation, and the EntityMode defines which tuplizer is in use.
285-
/// </summary>
286-
/// <param name="mode">Tuplizer entity-mode</param>
287-
/// <param name="tuplizerType">Tuplizer type</param>
288-
public TuplizerPart Tuplizer(TuplizerMode mode, Type tuplizerType) => CreateTuplizerPart(mode, tuplizerType);
289280

290281
SubclassMapping IIndeterminateSubclassMappingProvider.GetSubclassMapping(SubclassType type)
291282
{
@@ -339,9 +330,15 @@ SubclassMapping IIndeterminateSubclassMappingProvider.GetSubclassMapping(Subclas
339330
case MappingProviderStore.ProviderType.StoredProcedure:
340331
mapping.AddStoredProcedure(((IStoredProcedureMappingProvider)mappingProviderObj).GetStoredProcedureMapping());
341332
break;
333+
case MappingProviderStore.ProviderType.Subclass:
334+
case MappingProviderStore.ProviderType.Filter:
335+
case MappingProviderStore.ProviderType.Join:
336+
case MappingProviderStore.ProviderType.Identity:
337+
case MappingProviderStore.ProviderType.CompositeId:
338+
case MappingProviderStore.ProviderType.NaturalId:
339+
case MappingProviderStore.ProviderType.Version:
340+
case MappingProviderStore.ProviderType.Discriminator:
342341
case MappingProviderStore.ProviderType.Tupilizer:
343-
mapping.Set(y => y.Tuplizer, Layer.Defaults, (TuplizerMapping)mappingProviderObj);
344-
break;
345342
default:
346343
throw new Exception("Internal Error");
347344
}

0 commit comments

Comments
 (0)