Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 62b8f40

Browse files
committed
Use CreateDelegate ext method to fix PCL build
1 parent 5999f82 commit 62b8f40

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/ServiceStack.Text/Common/WriteType.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,17 @@ private static WriteObjectDelegate GetWriteFn()
105105
static Func<T, bool> GetShouldSerializeMethod(MemberInfo member)
106106
{
107107
var method = member.DeclaringType.GetInstanceMethod("ShouldSerialize" + member.Name);
108-
return (method == null || method.ReturnType != typeof(bool)) ? null : (Func<T, bool>)method.CreateDelegate(typeof(Func<T, bool>));
108+
return method == null || method.ReturnType != typeof(bool)
109+
? null
110+
: (Func<T, bool>)method.CreateDelegate(typeof(Func<T, bool>));
109111
}
110112

111113
static Func<T, string, bool?> ShouldSerialize(Type type)
112114
{
113115
var method = type.GetMethodInfo("ShouldSerialize");
114-
return (method == null || method.ReturnType != typeof(bool?))
116+
return method == null || method.ReturnType != typeof(bool?)
115117
? null
116-
: (Func<T, string, bool?>)Delegate.CreateDelegate(typeof(Func<T, string, bool?>), method);
118+
: (Func<T, string, bool?>)method.CreateDelegate(typeof(Func<T, string, bool?>));
117119
}
118120

119121
private static bool Init()

src/ServiceStack.Text/ReflectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ public static Func<object, string, object, object> GetOnDeserializing<T>()
672672
var method = typeof(T).GetMethodInfo("OnDeserializing");
673673
if (method == null || method.ReturnType != typeof(object))
674674
return null;
675-
var obj = (Func<T, string, object, object>)Delegate.CreateDelegate(typeof(Func<T, string, object, object>), method);
675+
var obj = (Func<T, string, object, object>)method.CreateDelegate(typeof(Func<T, string, object, object>));
676676
return (instance, memberName, value) => obj((T)instance, memberName, value);
677677
}
678678

0 commit comments

Comments
 (0)