You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.6 KiB
57 lines
1.6 KiB
#if !UNITY_WSA |
|
|
|
using System; |
|
using System.Collections.Generic; |
|
using System.Reflection; |
|
using System.Runtime.CompilerServices; |
|
using System.Text; |
|
|
|
namespace MessagePack.Internal |
|
{ |
|
internal static class ReflectionExtensions |
|
{ |
|
public static bool IsNullable(this System.Reflection.TypeInfo type) |
|
{ |
|
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(System.Nullable<>); |
|
} |
|
|
|
public static bool IsPublic(this System.Reflection.TypeInfo type) |
|
{ |
|
return type.IsPublic; |
|
} |
|
|
|
public static bool IsAnonymous(this System.Reflection.TypeInfo type) |
|
{ |
|
return type.GetCustomAttribute<CompilerGeneratedAttribute>() != null |
|
&& type.IsGenericType && type.Name.Contains("AnonymousType") |
|
&& (type.Name.StartsWith("<>") || type.Name.StartsWith("VB$")) |
|
&& (type.Attributes & TypeAttributes.NotPublic) == TypeAttributes.NotPublic; |
|
} |
|
|
|
public static bool IsIndexer(this System.Reflection.PropertyInfo propertyInfo) |
|
{ |
|
return propertyInfo.GetIndexParameters().Length > 0; |
|
} |
|
|
|
#if NETSTANDARD |
|
|
|
public static bool IsConstructedGenericType(this System.Reflection.TypeInfo type) |
|
{ |
|
return type.AsType().IsConstructedGenericType; |
|
} |
|
|
|
public static MethodInfo GetGetMethod(this PropertyInfo propInfo) |
|
{ |
|
return propInfo.GetMethod; |
|
} |
|
|
|
public static MethodInfo GetSetMethod(this PropertyInfo propInfo) |
|
{ |
|
return propInfo.SetMethod; |
|
} |
|
|
|
#endif |
|
} |
|
} |
|
|
|
#endif |