Skip to content

Commit 051f0ad

Browse files
committed
NH-3807 - Centeralize all use of string.Intern() and guard on use for CoreClr.
1 parent 8e42ee4 commit 051f0ad

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/NHibernate/Mapping/OneToMany.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using NHibernate.Engine;
44
using NHibernate.Type;
5+
using NHibernate.Util;
56

67
namespace NHibernate.Mapping
78
{
@@ -48,7 +49,7 @@ public int ColumnSpan
4849
public string ReferencedEntityName
4950
{
5051
get { return referencedEntityName; }
51-
set { referencedEntityName = value == null ? null : string.Intern(value); }
52+
set { referencedEntityName = StringHelper.InternedIfPossible(value); }
5253
}
5354

5455
public Table ReferencingTable
@@ -161,4 +162,4 @@ public bool IsEmbedded
161162
set { embedded = value; }
162163
}
163164
}
164-
}
165+
}

src/NHibernate/Mapping/PersistentClass.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public string ClassName
7171
get { return className; }
7272
set
7373
{
74-
className = value == null ? null : string.Intern(value);
74+
className = StringHelper.InternedIfPossible(value);
7575
mappedClass = null;
7676
}
7777
}
@@ -260,7 +260,7 @@ public virtual IEnumerable<Subclass> DirectSubclasses
260260
public virtual string EntityName
261261
{
262262
get { return entityName; }
263-
set { entityName = value == null ? null : String.Intern(value); }
263+
set { entityName = StringHelper.InternedIfPossible(value); }
264264
}
265265

266266
/// <summary>
@@ -520,7 +520,7 @@ public virtual IDictionary<string, string> FilterMap
520520
public string LoaderName
521521
{
522522
get { return loaderName; }
523-
set { loaderName = value == null ? null : string.Intern(value); }
523+
set { loaderName = StringHelper.InternedIfPossible(value); }
524524
}
525525

526526
public virtual ISet<string> SynchronizedTables

src/NHibernate/Util/StringHelper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,13 @@ public static string InternedIfPossible(string str)
675675
return null;
676676
}
677677

678+
#if FEATURE_STRING_INTERN
678679
string interned = string.IsInterned(str);
679680
if (interned != null)
680681
{
681682
return interned;
682683
}
684+
#endif
683685

684686
return str;
685687
}

0 commit comments

Comments
 (0)