Skip to content

Commit cefb7da

Browse files
committed
#105 - exclude only private nested classes from auto mapping
1 parent 2cd1819 commit cefb7da

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/FluentNHibernate.Specs/Automapping/AutomappingSpecs.NestedClasses.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ public class when_automapper_is_told_to_map_a_class_with_a_nested_classes
6262
Establish context = () =>
6363
{
6464
nonPublicNestedType = typeof(PersonCard).GetNestedTypes(BindingFlags.NonPublic).Single();
65-
model = AutoMap.Source(new StubTypeSource(typeof(PersonCard), typeof(PersonCard.PublicAddress), nonPublicNestedType),
66-
new DefaultAutomappingConfiguration());
65+
model = AutoMap.Source(new StubTypeSource(typeof(PersonCard), typeof(PersonCard.PublicAddress), nonPublicNestedType));
6766
};
6867

6968
Because of = () => mappings = model.BuildMappings().SelectMany(m => m.Classes);
69+
It should_map_the_main_class = () => mappings.ShouldContain(m => m.Type == typeof(PersonCard));
7070
It should_map_public_nested_class = () => mappings.ShouldContain(m => m.Type == typeof(PersonCard.PublicAddress));
71-
It should_not_map_not_public_nested_class = () => mappings.ShouldNotContain(m => m.Type == nonPublicNestedType);
71+
It should_not_map_non_public_nested_class = () => mappings.ShouldNotContain(m => m.Type == nonPublicNestedType);
7272

7373
static AutoPersistenceModel model;
7474
static DefaultAutomappingConfiguration configuration;

src/FluentNHibernate/Automapping/DefaultAutomappingConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public virtual bool ShouldMap(Type type)
1919
{
2020
return !type.ClosesInterface(typeof(IAutoMappingOverride<>)) &&
2121
!type.HasInterface(typeof(IMappingProvider)) &&
22-
(type.IsPublic || (type.IsNotPublic && !type.IsNested)) &&
22+
!type.IsNestedPrivate &&
2323
type.IsClass;
2424
}
2525

0 commit comments

Comments
 (0)