Fixed checks for delegates with no captured variables
このコミットが含まれているのは:
1 親
09eea2ddd5
コミット
c1fe54c63e
2ファイル変更
+13
-2
検索条件に一致するファイルはありません
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ComputeSharp.Shaders.Extensions
|
||||
@@ -20,6 +21,14 @@ namespace ComputeSharp.Shaders.Extensions
|
||||
public static bool IsDelegate(this Type type) => type.IsClass &&
|
||||
type.IsSubclassOf(typeof(Delegate));
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the input <see cref="Type"/> represents a <see cref="Delegate"/> with no captured variables
|
||||
/// </summary>
|
||||
/// <param name="type">The input type to analyze</param>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsStatelessDelegateContainer(this Type type) => type.GetFields(BindingFlags.Static | BindingFlags.Public).Length > 0;
|
||||
|
||||
/// <summary>
|
||||
/// The mapping of supported known types to display string
|
||||
/// </summary>
|
||||
|
||||
@@ -160,7 +160,8 @@ namespace ComputeSharp.Shaders.Translation
|
||||
foreach (FieldInfo fieldInfo in action.Method.DeclaringType.GetFields())
|
||||
{
|
||||
if (fieldInfo.FieldType.IsDelegate() &&
|
||||
fieldInfo.GetValue(action.Target) is Delegate func && func.Method.IsStatic &&
|
||||
fieldInfo.GetValue(action.Target) is Delegate func &&
|
||||
(func.Method.IsStatic || func.Method.DeclaringType.IsStatelessDelegateContainer()) &&
|
||||
(HlslKnownTypes.IsKnownScalarType(func.Method.ReturnType) || HlslKnownTypes.IsKnownVectorType(func.Method.ReturnType)) &&
|
||||
fieldInfo.FieldType.GenericTypeArguments.All(type => HlslKnownTypes.IsKnownScalarType(type) ||
|
||||
HlslKnownTypes.IsKnownVectorType(type)))
|
||||
@@ -271,7 +272,8 @@ namespace ComputeSharp.Shaders.Translation
|
||||
}
|
||||
}
|
||||
else if (fieldType.IsDelegate() &&
|
||||
memberInfo.GetValue(Action.Target) is Delegate func && func.Method.IsStatic &&
|
||||
memberInfo.GetValue(Action.Target) is Delegate func &&
|
||||
(func.Method.IsStatic || func.Method.DeclaringType.IsStatelessDelegateContainer()) &&
|
||||
(HlslKnownTypes.IsKnownScalarType(func.Method.ReturnType) || HlslKnownTypes.IsKnownVectorType(func.Method.ReturnType)) &&
|
||||
fieldType.GenericTypeArguments.All(type => HlslKnownTypes.IsKnownScalarType(type) ||
|
||||
HlslKnownTypes.IsKnownVectorType(type)))
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする