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

Commit 69160b1

Browse files
committed
Add missing GetModule/GetGetMethod/GetSetMethod Wrapper APIs
1 parent 6db7339 commit 69160b1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/ServiceStack.Text/PlatformExtensions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,17 @@ public static MethodInfo Method(this Delegate fn)
313313
#endif
314314
}
315315

316+
317+
#if (NETFX_CORE || PCL || NETSTANDARD1_1)
318+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
319+
public static MethodInfo GetGetMethod(this PropertyInfo pi) =>
320+
pi.GetMethod;
321+
322+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
323+
public static MethodInfo GetSetMethod(this PropertyInfo pi, bool nonPublic=true) =>
324+
pi.SetMethod(nonPublic);
325+
#endif
326+
316327
[MethodImpl(MethodImplOptions.AggressiveInlining)]
317328
public static bool HasAttribute<T>(this Type type)
318329
{

src/ServiceStack.Text/ReflectionExtensions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,19 @@ public static object CreateInstance(string typeName)
624624
return ctorFn();
625625
}
626626

627+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
628+
public static Module GetModule(this Type type)
629+
{
630+
if (type == null)
631+
return null;
632+
633+
#if NETSTANDARD1_1
634+
return type.GetTypeInfo().Module;
635+
#else
636+
return type.Module;
637+
#endif
638+
}
639+
627640
public static PropertyInfo[] GetAllProperties(this Type type)
628641
{
629642
if (type.IsInterface())

0 commit comments

Comments
 (0)