Skip to content

Commit 130d922

Browse files
committed
NH-3723 - Swallow the Exception if Type of a property could not be loaded.
1 parent cd73db7 commit 130d922

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed
Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
1+
using System;
12
using System.Linq;
3+
using NHibernate.Mapping;
4+
using NHibernate.Type;
25

36

47
namespace NHibernate.Cfg.XmlHbmBinding
58
{
69
public static class MappingLogExtensions
710
{
8-
public static void LogMapped(this Mapping.Property property, IInternalLogger log)
11+
public static void LogMapped(this Property property, IInternalLogger log)
912
{
1013
if (log.IsDebugEnabled)
1114
{
12-
string msg = "Mapped property: " + property.Name;
13-
string columns = string.Join(",", property.Value.ColumnIterator.Select(c => c.Text).ToArray());
15+
var msg = "Mapped property: " + property.Name;
16+
var columns = string.Join(",", property.Value.ColumnIterator.Select(c => c.Text).ToArray());
1417
if (columns.Length > 0)
1518
msg += " -> " + columns;
16-
if (property.Type != null)
17-
msg += ", type: " + property.Type.Name;
19+
var propertyTypeName = SafeGetPropertyTypeName(property);
20+
if (propertyTypeName != null)
21+
msg += ", type: " + propertyTypeName;
1822
log.Debug(msg);
1923
}
2024
}
25+
26+
static string SafeGetPropertyTypeName(Property property)
27+
{
28+
try
29+
{
30+
//property.Type property can trigger a type load
31+
if (property.Type != null) return property.Type.Name;
32+
}
33+
catch (Exception)
34+
{
35+
return "<could not load type>";
36+
}
37+
return null;
38+
}
2139
}
22-
}
40+
}

0 commit comments

Comments
 (0)