Skip to content

Commit 72ecfe6

Browse files
committed
Modified TypeReference.IsEnum to return true if its wrapping a GenericEnumMapper.
1 parent 7034ece commit 72ecfe6

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@
464464
<Compile Include="MappingModel\Identity\CompositeIdMappingTester.cs" />
465465
<Compile Include="MappingModel\Output\XmlNaturalIdWriterTester.cs" />
466466
<Compile Include="MappingModel\SortingTests.cs" />
467+
<Compile Include="Utils\TypeReferenceEnumTests.cs" />
467468
</ItemGroup>
468469
<ItemGroup>
469470
<Content Include="..\..\tools\NHibernate\NHibernate.ByteCode.Castle.dll">
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using FluentNHibernate.MappingModel;
2+
using NUnit.Framework;
3+
using FluentNHibernate.Mapping;
4+
5+
namespace FluentNHibernate.Testing.Utils
6+
{
7+
[TestFixture]
8+
public class TypeReferenceEnumTests
9+
{
10+
[Test]
11+
public void IsEnumOnTypeReferenceToGenericEnumMapperShouldBeTrue()
12+
{
13+
var enumTypeReference = new TypeReference(typeof(GenericEnumMapper<TestEnum>));
14+
enumTypeReference.IsEnum.ShouldBeTrue();
15+
}
16+
17+
private enum TestEnum
18+
{
19+
Value1
20+
}
21+
22+
23+
}
24+
}

src/FluentNHibernate/MappingModel/TypeReference.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ public bool IsEnum
3535
if (innerType == null)
3636
return false;
3737

38+
if (innerType.IsGenericType
39+
&& innerType.GetGenericTypeDefinition() == typeof(FluentNHibernate.Mapping.GenericEnumMapper<>))
40+
{
41+
return true;
42+
}
43+
44+
3845
return innerType.IsEnum;
3946
}
4047
}

0 commit comments

Comments
 (0)