Minor code tweaks

このコミットが含まれているのは:
Sergio Pedri committed 2019-09-05 16:46:55 +02:00
1 親 cb47e24399
コミット 09eea2ddd5
2ファイル変更
+12 -2

検索条件に一致するファイルはありません

+10
ファイルの表示
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Runtime.CompilerServices;
namespace ComputeSharp.Shaders.Extensions
{
@@ -10,6 +11,15 @@ namespace ComputeSharp.Shaders.Extensions
/// </summary>
internal static class TypeExtensions
{
/// <summary>
/// Gets whether or not the input <see cref="Type"/> represents a <see cref="Delegate"/>
/// </summary>
/// <param name="type">The input type to analyze</param>
[Pure]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsDelegate(this Type type) => type.IsClass &&
type.IsSubclassOf(typeof(Delegate));
/// <summary>
/// The mapping of supported known types to display string
/// </summary>
+2 -2
ファイルの表示
@@ -159,7 +159,7 @@ namespace ComputeSharp.Shaders.Translation
foreach (FieldInfo fieldInfo in action.Method.DeclaringType.GetFields())
{
if (fieldInfo.FieldType.IsClass && fieldInfo.FieldType.IsGenericType &&
if (fieldInfo.FieldType.IsDelegate() &&
fieldInfo.GetValue(action.Target) is Delegate func && func.Method.IsStatic &&
(HlslKnownTypes.IsKnownScalarType(func.Method.ReturnType) || HlslKnownTypes.IsKnownVectorType(func.Method.ReturnType)) &&
fieldInfo.FieldType.GenericTypeArguments.All(type => HlslKnownTypes.IsKnownScalarType(type) ||
@@ -270,7 +270,7 @@ namespace ComputeSharp.Shaders.Translation
LoadFieldInfo(fieldInfo, null, updatedParents);
}
}
else if (fieldType.IsClass && fieldType.IsGenericType &&
else if (fieldType.IsDelegate() &&
memberInfo.GetValue(Action.Target) is Delegate func && func.Method.IsStatic &&
(HlslKnownTypes.IsKnownScalarType(func.Method.ReturnType) || HlslKnownTypes.IsKnownVectorType(func.Method.ReturnType)) &&
fieldType.GenericTypeArguments.All(type => HlslKnownTypes.IsKnownScalarType(type) ||