From 600b9edf9ba67ca956daa8494e7e8ac1e6795fb0 Mon Sep 17 00:00:00 2001 From: Roman Artiukhin Date: Mon, 4 Feb 2019 20:12:32 +0200 Subject: [PATCH 01/11] Avoid some cases of Type -> string -> Type conversion in Mapping By Code --- .../Mapping/ByCode/Impl/TypeNameUtil.cs | 4 +- src/NHibernate/Type/TypeFactory.cs | 82 +++++++++++++------ 2 files changed, 61 insertions(+), 25 deletions(-) diff --git a/src/NHibernate/Mapping/ByCode/Impl/TypeNameUtil.cs b/src/NHibernate/Mapping/ByCode/Impl/TypeNameUtil.cs index ecb05487972..f11089fe234 100644 --- a/src/NHibernate/Mapping/ByCode/Impl/TypeNameUtil.cs +++ b/src/NHibernate/Mapping/ByCode/Impl/TypeNameUtil.cs @@ -8,7 +8,7 @@ public static class TypeNameUtil public static string GetNhTypeName(this System.Type type) { string typeName; - IType nhType = TypeFactory.HeuristicType(type.AssemblyQualifiedName); + IType nhType = TypeFactory.HeuristicType(type); if (nhType != null) { typeName = nhType.Name; @@ -68,4 +68,4 @@ private static string GetTypeNameForMapping(System.Type type) return type.Name; } } -} \ No newline at end of file +} diff --git a/src/NHibernate/Type/TypeFactory.cs b/src/NHibernate/Type/TypeFactory.cs index 7658bc81905..40d7d3e6966 100644 --- a/src/NHibernate/Type/TypeFactory.cs +++ b/src/NHibernate/Type/TypeFactory.cs @@ -522,6 +522,22 @@ public static IType HeuristicType(string typeName) return HeuristicType(typeName, null); } + /// + /// Uses heuristics to deduce a NHibernate type given a string naming the + /// type. + /// + /// + /// An instance of NHibernate.Type.IType + /// + /// We check to see if it implements IType, ICompositeUserType, IUserType, ILifecycle (Association), or + /// IPersistentEnum. If none of those are implemented then we will serialize the Type to the + /// database using NHibernate.Type.SerializableType(typeName) + /// + public static IType HeuristicType(System.Type type) + { + return HeuristicType(type, parameters: null, length: null); + } + /// /// Uses heuristics to deduce a NHibernate type given a string naming the type. /// @@ -532,7 +548,7 @@ public static IType HeuristicType(string typeName, IDictionary p { return HeuristicType(typeName, parameters, null); } - + /// /// Uses heuristics to deduce a NHibernate type given a string naming the type. /// @@ -546,15 +562,21 @@ public static IType HeuristicType(string typeName, IDictionary p if (type != null) return type; - + string[] parsedTypeName; - TypeClassification typeClassification = GetTypeClassification(typeName); + var typeClassification = GetTypeClassification(typeName); if (typeClassification == TypeClassification.LengthOrScale) + { parsedTypeName = typeName.Split(LengthSplit); + if (!int.TryParse(parsedTypeName[1], out int parsedLength)) + { + throw new MappingException($"Could not parse length value '{parsedTypeName[1]}' as int for type '{typeName}'"); + } + length = parsedLength; + } else parsedTypeName = typeClassification == TypeClassification.PrecisionScale ? typeName.Split(PrecisionScaleSplit) : new[] { typeName }; - System.Type typeClass; try { @@ -562,30 +584,42 @@ public static IType HeuristicType(string typeName, IDictionary p } catch (Exception) { - typeClass = null; + return null; } + return HeuristicType(typeClass, parameters, length, false); + } - if (typeClass == null) - return null; - + private static IType HeuristicType(System.Type typeClass, IDictionary parameters, int? length, bool tryBasic = true) + { + if(tryBasic) + { + IType type = Basic(typeClass.AssemblyQualifiedName, parameters); + + if (type != null) + return type; + } if (typeof(IType).IsAssignableFrom(typeClass)) { try { - type = (IType) Environment.ObjectsFactory.CreateInstance(typeClass); + var type = (IType) Environment.ObjectsFactory.CreateInstance(typeClass); + InjectParameters(type, parameters); + + var obsolete = typeClass.GetCustomAttribute(false); + if (obsolete != null) + { + _log.Warn("{0} is obsolete. {1}", typeClass.AssemblyQualifiedName, obsolete.Message); + } + return type; } - catch (Exception e) + catch (HibernateException) { - throw new MappingException("Could not instantiate IType " + typeClass.Name + ": " + e, e); + throw; } - InjectParameters(type, parameters); - - var obsolete = typeClass.GetCustomAttribute(false); - if (obsolete != null) + catch (Exception e) { - _log.Warn("{0} is obsolete. {1}", typeName, obsolete.Message); + throw new MappingException("Could not instantiate IType " + typeClass.Name + ": " + e, e); } - return type; } if (typeof(ICompositeUserType).IsAssignableFrom(typeClass)) { @@ -603,19 +637,16 @@ public static IType HeuristicType(string typeName, IDictionary p var unwrapped = typeClass.UnwrapIfNullable(); if (unwrapped.IsEnum) { - return (IType) Activator.CreateInstance(typeof (EnumType<>).MakeGenericType(unwrapped)); + return (IType) Activator.CreateInstance(typeof(EnumType<>).MakeGenericType(unwrapped)); } if (!typeClass.IsSerializable) return null; - if (typeClassification == TypeClassification.LengthOrScale) - return GetSerializableType(typeClass, Int32.Parse(parsedTypeName[1])); - if (length.HasValue) return GetSerializableType(typeClass, length.Value); - return GetSerializableType(typeClass); + return GetSerializedOrBasicType(typeClass); } /// @@ -683,6 +714,11 @@ private static NullableType GetType(NullableType defaultUnqualifiedType, byte pr /// /// public static NullableType GetSerializableType(System.Type serializableType) + { + return (NullableType) GetSerializedOrBasicType(serializableType); + } + + private static IType GetSerializedOrBasicType(System.Type serializableType) { var key = serializableType.AssemblyQualifiedName; @@ -690,7 +726,7 @@ public static NullableType GetSerializableType(System.Type serializableType) // So we should add the type with its other key in a later operation in order to ensure we cache the same // instance for both keys. var added = false; - var type = (NullableType)typeByTypeOfName.GetOrAdd( + var type = typeByTypeOfName.GetOrAdd( key, k => { From 181b4bcbf72b9e6a432210089d14a2f5770427f9 Mon Sep 17 00:00:00 2001 From: Roman Artiukhin Date: Tue, 5 Feb 2019 00:06:08 +0200 Subject: [PATCH 02/11] Throw exception on wrong typeName --- src/NHibernate/Type/TypeFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NHibernate/Type/TypeFactory.cs b/src/NHibernate/Type/TypeFactory.cs index 40d7d3e6966..1669d31afe3 100644 --- a/src/NHibernate/Type/TypeFactory.cs +++ b/src/NHibernate/Type/TypeFactory.cs @@ -582,9 +582,9 @@ public static IType HeuristicType(string typeName, IDictionary p { typeClass = ReflectHelper.ClassForName(parsedTypeName[0]); //typeName); } - catch (Exception) + catch (Exception ex) { - return null; + throw new MappingException("Could not find IType for given" + typeName + ": " + ex, ex); } return HeuristicType(typeClass, parameters, length, false); } From 9da661e5a96cf21e421b347d29304681db822860 Mon Sep 17 00:00:00 2001 From: Roman Artiukhin Date: Tue, 5 Feb 2019 06:14:59 +0200 Subject: [PATCH 03/11] Revert "Throw exception on wrong typeName" This reverts commit 181b4bcbf72b9e6a432210089d14a2f5770427f9. --- src/NHibernate/Type/TypeFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NHibernate/Type/TypeFactory.cs b/src/NHibernate/Type/TypeFactory.cs index 1669d31afe3..40d7d3e6966 100644 --- a/src/NHibernate/Type/TypeFactory.cs +++ b/src/NHibernate/Type/TypeFactory.cs @@ -582,9 +582,9 @@ public static IType HeuristicType(string typeName, IDictionary p { typeClass = ReflectHelper.ClassForName(parsedTypeName[0]); //typeName); } - catch (Exception ex) + catch (Exception) { - throw new MappingException("Could not find IType for given" + typeName + ": " + ex, ex); + return null; } return HeuristicType(typeClass, parameters, length, false); } From 96ad8785ed562260a95e68a0e78c2d77bbacb8dd Mon Sep 17 00:00:00 2001 From: Roman Artiukhin Date: Tue, 5 Feb 2019 07:35:20 +0200 Subject: [PATCH 04/11] Adjust obsolete message --- src/NHibernate.Test/TypesTest/TimestampTypeFixture.cs | 5 +---- src/NHibernate/Type/TypeFactory.cs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/NHibernate.Test/TypesTest/TimestampTypeFixture.cs b/src/NHibernate.Test/TypesTest/TimestampTypeFixture.cs index 5cd6b53d3fc..1299dd2c357 100644 --- a/src/NHibernate.Test/TypesTest/TimestampTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/TimestampTypeFixture.cs @@ -24,10 +24,7 @@ public void ObsoleteMessage() var log = spy.GetWholeLog(); Assert.That( log, - Does.Contain("NHibernate.Type.TimestampType is obsolete. Please use DateTimeType instead.").IgnoreCase); - Assert.That( - log, - Does.Not.Contain($"{NHibernateUtil.Timestamp.Name} is obsolete. Please use DateTimeType instead.").IgnoreCase); + Does.Contain($"NHibernate.Type.TimestampType ({NHibernateUtil.Timestamp.Name}) is obsolete. Please use DateTimeType instead.").IgnoreCase); } } } diff --git a/src/NHibernate/Type/TypeFactory.cs b/src/NHibernate/Type/TypeFactory.cs index 40d7d3e6966..a793f72d87a 100644 --- a/src/NHibernate/Type/TypeFactory.cs +++ b/src/NHibernate/Type/TypeFactory.cs @@ -608,7 +608,7 @@ private static IType HeuristicType(System.Type typeClass, IDictionary(false); if (obsolete != null) { - _log.Warn("{0} is obsolete. {1}", typeClass.AssemblyQualifiedName, obsolete.Message); + _log.Warn("{0} ({1}) is obsolete. {2}", typeClass.Namespace + "." + typeClass.Name, type.Name, obsolete.Message); } return type; } From 4a441ecc7b1a3653198c8c65d17bcd1bfc567fb0 Mon Sep 17 00:00:00 2001 From: Roman Artiukhin Date: Tue, 5 Feb 2019 07:42:15 +0200 Subject: [PATCH 05/11] Avoid parsing in Basic lookup --- src/NHibernate/Type/TypeFactory.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/NHibernate/Type/TypeFactory.cs b/src/NHibernate/Type/TypeFactory.cs index a793f72d87a..f06e0c1ebb2 100644 --- a/src/NHibernate/Type/TypeFactory.cs +++ b/src/NHibernate/Type/TypeFactory.cs @@ -404,6 +404,11 @@ public static IType Basic(string name) /// This method will return null if the name is not found in the basicNameMap. /// public static IType Basic(string name, IDictionary parameters) + { + return Basic(name, parameters, parseName: true); + } + + private static IType Basic(string name, IDictionary parameters, bool parseName) { string typeName; @@ -426,6 +431,9 @@ public static IType Basic(string name, IDictionary parameters) return returnType; } + if (!parseName) + return null; + // if we get to here then the basic type with the length or precision/scale // combination doesn't exists - so lets figure out which one we have and // invoke the appropriate delegate @@ -593,7 +601,7 @@ private static IType HeuristicType(System.Type typeClass, IDictionary Date: Tue, 5 Feb 2019 07:46:07 +0200 Subject: [PATCH 06/11] Final call should be to GetSerializableType --- src/NHibernate/Type/TypeFactory.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/NHibernate/Type/TypeFactory.cs b/src/NHibernate/Type/TypeFactory.cs index f06e0c1ebb2..d040abc3f9e 100644 --- a/src/NHibernate/Type/TypeFactory.cs +++ b/src/NHibernate/Type/TypeFactory.cs @@ -654,7 +654,7 @@ private static IType HeuristicType(System.Type typeClass, IDictionary @@ -722,11 +722,6 @@ private static NullableType GetType(NullableType defaultUnqualifiedType, byte pr /// /// public static NullableType GetSerializableType(System.Type serializableType) - { - return (NullableType) GetSerializedOrBasicType(serializableType); - } - - private static IType GetSerializedOrBasicType(System.Type serializableType) { var key = serializableType.AssemblyQualifiedName; @@ -747,7 +742,7 @@ private static IType GetSerializedOrBasicType(System.Type serializableType) throw new HibernateException($"Another item with the key {type.Name} has already been added to typeByTypeOfName."); } - return type; + return (NullableType) type; } public static NullableType GetSerializableType(System.Type serializableType, int length) From 92f8a9c29f9081e8411fd698297fe19ce958d711 Mon Sep 17 00:00:00 2001 From: Roman Artiukhin Date: Tue, 5 Feb 2019 11:14:44 +0200 Subject: [PATCH 07/11] Address comments --- src/NHibernate/Type/TypeFactory.cs | 57 ++++++++++++++---------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/src/NHibernate/Type/TypeFactory.cs b/src/NHibernate/Type/TypeFactory.cs index d040abc3f9e..f4d27d117ab 100644 --- a/src/NHibernate/Type/TypeFactory.cs +++ b/src/NHibernate/Type/TypeFactory.cs @@ -405,34 +405,11 @@ public static IType Basic(string name) /// public static IType Basic(string name, IDictionary parameters) { - return Basic(name, parameters, parseName: true); - } - - private static IType Basic(string name, IDictionary parameters, bool parseName) - { - string typeName; - // Use the basic name (such as String or String(255)) to get the - // instance of the IType object. - IType returnType; - if (typeByTypeOfName.TryGetValue(name, out returnType)) - { - if (_obsoleteMessageByAlias.TryGetValue(name, out string obsoleteMessage)) - _log.Warn("{0} is obsolete. {1}", name, obsoleteMessage); - - if (parameters?.Count > 0 && returnType is IParameterizedType) - { - // The type is parameterized, must apply the parameters to a new instance of the type. - // Some built-in types have internal default constructor like StringType, so we need to - // allow non-public constructors. - returnType = (IType) Activator.CreateInstance(returnType.GetType(), true); - InjectParameters(returnType, parameters); - } + // instance of the IType object. + var returnType = GetBasicTypeByName(name, parameters); + if (returnType != null) return returnType; - } - - if (!parseName) - return null; // if we get to here then the basic type with the length or precision/scale // combination doesn't exists - so lets figure out which one we have and @@ -450,7 +427,7 @@ private static IType Basic(string name, IDictionary parameters, "TypeClassification.PrecisionScale", name, "It is not a valid Precision/Scale name"); } - typeName = parsedName[0].Trim(); + string typeName = parsedName[0].Trim(); byte precision = Byte.Parse(parsedName[1].Trim()); byte scale = Byte.Parse(parsedName[2].Trim()); @@ -467,7 +444,7 @@ private static IType Basic(string name, IDictionary parameters, "TypeClassification.LengthOrScale", name, "It is not a valid Length or Scale name"); } - typeName = parsedName[0].Trim(); + string typeName = parsedName[0].Trim(); int length = Int32.Parse(parsedName[1].Trim()); returnType = BuiltInType(typeName, length); @@ -486,6 +463,26 @@ private static IType Basic(string name, IDictionary parameters, return returnType; } + private static IType GetBasicTypeByName(string name, IDictionary parameters) + { + if (typeByTypeOfName.TryGetValue(name, out var returnType)) + { + if (_obsoleteMessageByAlias.TryGetValue(name, out string obsoleteMessage)) + _log.Warn("{0} is obsolete. {1}", name, obsoleteMessage); + + if (parameters?.Count > 0 && returnType is IParameterizedType) + { + // The type is parameterized, must apply the parameters to a new instance of the type. + // Some built-in types have internal default constructor like StringType, so we need to + // allow non-public constructors. + returnType = (IType) Activator.CreateInstance(returnType.GetType(), true); + InjectParameters(returnType, parameters); + } + return returnType; + } + return null; + } + internal static IType BuiltInType(string typeName, int lengthOrScale) { GetNullableTypeWithLengthOrScale lengthOrScaleDelegate; @@ -601,7 +598,7 @@ private static IType HeuristicType(System.Type typeClass, IDictionary(false); if (obsolete != null) { - _log.Warn("{0} ({1}) is obsolete. {2}", typeClass.Namespace + "." + typeClass.Name, type.Name, obsolete.Message); + _log.Warn("{0} ({1}) is obsolete. {2}", typeClass.FullName, type.Name, obsolete.Message); } return type; } From ef048eb7eafe50a99d84c564032a10e5ba2c43c3 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Tue, 5 Feb 2019 22:27:19 +1300 Subject: [PATCH 08/11] Inline another boolean flag --- src/NHibernate/Type/TypeFactory.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/NHibernate/Type/TypeFactory.cs b/src/NHibernate/Type/TypeFactory.cs index f4d27d117ab..1901f6f14a4 100644 --- a/src/NHibernate/Type/TypeFactory.cs +++ b/src/NHibernate/Type/TypeFactory.cs @@ -540,7 +540,8 @@ public static IType HeuristicType(string typeName) /// public static IType HeuristicType(System.Type type) { - return HeuristicType(type, parameters: null, length: null); + return GetBasicTypeByName(type.AssemblyQualifiedName, null) ?? + HeuristicType(type, null, null); } /// @@ -591,18 +592,12 @@ public static IType HeuristicType(string typeName, IDictionary p { return null; } - return HeuristicType(typeClass, parameters, length, false); + + return HeuristicType(typeClass, parameters, length); } - private static IType HeuristicType(System.Type typeClass, IDictionary parameters, int? length, bool tryBasic = true) + private static IType HeuristicType(System.Type typeClass, IDictionary parameters, int? length) { - if(tryBasic) - { - IType type = GetBasicTypeByName(typeClass.AssemblyQualifiedName, parameters); - - if (type != null) - return type; - } if (typeof(IType).IsAssignableFrom(typeClass)) { try @@ -615,6 +610,7 @@ private static IType HeuristicType(System.Type typeClass, IDictionary Date: Tue, 5 Feb 2019 22:27:44 +1300 Subject: [PATCH 09/11] Add tests --- .../TypesTest/TypeFactoryFixture.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs b/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs index 33890ae7585..b7b870d3f43 100644 --- a/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs +++ b/src/NHibernate.Test/TypesTest/TypeFactoryFixture.cs @@ -56,6 +56,7 @@ public void GetNullableGeneric() //Assert.AreEqual(int64Type, TypeFactory.HeuristicType("Int64?"), "'Int64?' should return a NH Int64Type"); System.Type reflectedType = Util.ReflectHelper.ReflectedPropertyClass( typeof(GenericPropertyClass), "GenericInt64", "property" ); + Assert.AreEqual( int64Type, TypeFactory.HeuristicType( reflectedType ), "using System.Type should return nh Int64Type" ); Assert.AreEqual( int64Type, TypeFactory.HeuristicType( reflectedType.AssemblyQualifiedName ), "using AQN should return nh Int64Type" ); Assert.AreEqual( int64Type, TypeFactory.HeuristicType( reflectedType.FullName ), "using FullName should return nh Int64Type" ); @@ -143,5 +144,19 @@ public void WhenUseNullableEnumThenReturnGenericEnumType() var iType = TypeFactory.HeuristicType(typeof(MyEnum?).AssemblyQualifiedName); Assert.That(iType, Is.TypeOf>()); } + + [Test] + public void WhenUseEnumTypeThenReturnGenericEnumType() + { + var iType = TypeFactory.HeuristicType(typeof (MyEnum)); + Assert.That(iType, Is.TypeOf>()); + } + + [Test] + public void WhenUseNullableEnumTypeThenReturnGenericEnumType() + { + var iType = TypeFactory.HeuristicType(typeof(MyEnum?)); + Assert.That(iType, Is.TypeOf>()); + } } } From 935e8ee6115c42065f34768b44e5e1d259379f97 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Tue, 5 Feb 2019 22:27:56 +1300 Subject: [PATCH 10/11] Use new method in more places --- .../Hql/Ast/ANTLR/Tree/JavaConstantNode.cs | 2 +- src/NHibernate/Impl/AbstractQueryImpl.cs | 30 +++++++------------ src/NHibernate/Util/ReflectHelper.cs | 2 +- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs b/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs index d7cece9236e..07da64e1099 100644 --- a/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs +++ b/src/NHibernate/Hql/Ast/ANTLR/Tree/JavaConstantNode.cs @@ -70,7 +70,7 @@ private void ProcessText() } _constantValue = ReflectHelper.GetConstantValue(base.Text, _factory); - _heuristicType = TypeFactory.HeuristicType(_constantValue.GetType().AssemblyQualifiedName); + _heuristicType = TypeFactory.HeuristicType(_constantValue.GetType()); _processedText = true; } } diff --git a/src/NHibernate/Impl/AbstractQueryImpl.cs b/src/NHibernate/Impl/AbstractQueryImpl.cs index e16a63f7a91..5106a7d33e3 100644 --- a/src/NHibernate/Impl/AbstractQueryImpl.cs +++ b/src/NHibernate/Impl/AbstractQueryImpl.cs @@ -196,32 +196,22 @@ private IType GuessType(System.Type clazz) throw new ArgumentNullException("clazz", "The IType can not be guessed for a null value."); } - string typename = clazz.AssemblyQualifiedName; - IType type = TypeFactory.HeuristicType(typename); - bool serializable = (type != null && type is SerializableType); - if (type == null || serializable) + var type = TypeFactory.HeuristicType(clazz); + if (type == null || type is SerializableType) { - try + if (session.Factory.TryGetEntityPersister(clazz.FullName) != null) { - session.Factory.GetEntityPersister(clazz.FullName); + return NHibernateUtil.Entity(clazz); } - catch (MappingException) + + if (type == null) { - if (serializable) - { - return type; - } - else - { - throw new HibernateException("Could not determine a type for class: " + typename); - } + throw new HibernateException( + "Could not determine a type for class: " + clazz.AssemblyQualifiedName); } - return NHibernateUtil.Entity(clazz); - } - else - { - return type; } + + return type; } /// diff --git a/src/NHibernate/Util/ReflectHelper.cs b/src/NHibernate/Util/ReflectHelper.cs index 20c4bfa87b0..7de13090ff7 100644 --- a/src/NHibernate/Util/ReflectHelper.cs +++ b/src/NHibernate/Util/ReflectHelper.cs @@ -293,7 +293,7 @@ public static IType ReflectedPropertyType(System.Type theClass, string name, str var heuristicClass = propertyClass.UnwrapIfNullable(); - return TypeFactory.HeuristicType(heuristicClass.AssemblyQualifiedName); + return TypeFactory.HeuristicType(heuristicClass); } /// From 012dbdb215728715771b8d97b6220589d2f616ad Mon Sep 17 00:00:00 2001 From: Roman Artiukhin Date: Tue, 5 Feb 2019 12:30:49 +0200 Subject: [PATCH 11/11] Renamed --- src/NHibernate/Type/TypeFactory.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NHibernate/Type/TypeFactory.cs b/src/NHibernate/Type/TypeFactory.cs index 1901f6f14a4..4bc8757e88e 100644 --- a/src/NHibernate/Type/TypeFactory.cs +++ b/src/NHibernate/Type/TypeFactory.cs @@ -540,8 +540,8 @@ public static IType HeuristicType(string typeName) /// public static IType HeuristicType(System.Type type) { - return GetBasicTypeByName(type.AssemblyQualifiedName, null) ?? - HeuristicType(type, null, null); + return GetBasicTypeByName(type.AssemblyQualifiedName, null) + ?? GetBySystemType(type, null, null); } /// @@ -593,10 +593,10 @@ public static IType HeuristicType(string typeName, IDictionary p return null; } - return HeuristicType(typeClass, parameters, length); + return GetBySystemType(typeClass, parameters, length); } - private static IType HeuristicType(System.Type typeClass, IDictionary parameters, int? length) + private static IType GetBySystemType(System.Type typeClass, IDictionary parameters, int? length) { if (typeof(IType).IsAssignableFrom(typeClass)) {