Skip to content

Commit a096286

Browse files
committed
NH-3807 - Other misc reflection changes for CoreClr.
1 parent 9c7ce64 commit a096286

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/NHibernate/Bytecode/EmitUtil.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,11 @@ public static void EmitLoadMethodInfo(ILGenerator il, MethodInfo methodInfo)
205205
public static void EmitCreateDelegateInstance(ILGenerator il, System.Type delegateType, MethodInfo methodInfo)
206206
{
207207
MethodInfo createDelegate = typeof(Delegate).GetMethod(
208-
"CreateDelegate", BindingFlags.Static | BindingFlags.Public | BindingFlags.ExactBinding, null,
209-
new System.Type[] {typeof(System.Type), typeof(MethodInfo)}, null);
208+
"CreateDelegate", BindingFlags.Static | BindingFlags.Public
209+
#if !NETSTANDARD
210+
| BindingFlags.ExactBinding
211+
#endif
212+
, null, new System.Type[] {typeof(System.Type), typeof(MethodInfo)}, null);
210213

211214
EmitLoadType(il, delegateType);
212215
EmitLoadMethodInfo(il, methodInfo);

src/NHibernate/Cfg/Environment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static string Version
5151
{
5252
if (cachedVersion == null)
5353
{
54-
Assembly thisAssembly = Assembly.GetExecutingAssembly();
54+
Assembly thisAssembly = typeof(Environment).GetTypeInfo().Assembly;
5555
var attrs =
5656
thisAssembly.GetCustomAttributes<AssemblyInformationalVersionAttribute>().ToArray();
5757

src/NHibernate/Proxy/DynamicProxy/ProxyFactory.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ private System.Type CreateUncachedProxyType(System.Type baseType, System.Type[]
157157
// Make the proxy serializable
158158
AddSerializationSupport(baseType, baseInterfaces, typeBuilder, interceptorField, defaultConstructor);
159159
#endif
160+
161+
#if FEATURE_LEGACY_REFLECTION_API
160162
System.Type proxyType = typeBuilder.CreateType();
163+
#else
164+
System.Type proxyType = typeBuilder.CreateTypeInfo().AsType();
165+
#endif
161166

162167
ProxyAssemblyBuilder.Save(assemblyBuilder);
163168
return proxyType;

src/NHibernate/Util/ReflectHelper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
using NHibernate.Type;
1010
using NHibernate.Engine;
1111

12+
#if NETSTANDARD
13+
using Microsoft.Extensions.DependencyModel;
14+
#endif
15+
1216
namespace NHibernate.Util
1317
{
1418
/// <summary>
@@ -219,7 +223,11 @@ public static System.Type ClassForFullNameOrNull(string classFullName)
219223
{
220224
if (!string.IsNullOrEmpty(classFullName))
221225
{
226+
#if NETSTANDARD
227+
Assembly[] ass = DependencyContext.Default.RuntimeLibraries.SelectMany(l => l.Assemblies).Select(x => Assembly.Load(x.Name)).ToArray();
228+
#else
222229
Assembly[] ass = AppDomain.CurrentDomain.GetAssemblies();
230+
#endif
223231
foreach (Assembly a in ass)
224232
{
225233
result = a.GetType(classFullName, false, false);

0 commit comments

Comments
 (0)