diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs index 8a16eeba..27f03881 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs @@ -31,11 +31,6 @@ namespace ComputeSharp.Shaders.Translation /// private readonly object ShaderInstance; - /// - /// The sequence of fields in the targeted closure - /// - private readonly IReadOnlyList ShaderFields; - /// /// Creates a new with the specified parameters /// @@ -45,7 +40,6 @@ namespace ComputeSharp.Shaders.Translation Action = action; ShaderType = action.Method.DeclaringType; ShaderInstance = action.Target; - ShaderFields = ShaderType.GetFields().ToArray(); } /// @@ -123,7 +117,8 @@ namespace ComputeSharp.Shaders.Translation /// private void LoadFieldsInfo() { - if (ShaderFields.Any(fieldInfo => fieldInfo.IsStatic)) throw new InvalidOperationException("Empty shader body"); + IReadOnlyList shaderFields = ShaderType.GetFields().ToArray(); + if (shaderFields.Any(fieldInfo => fieldInfo.IsStatic)) throw new InvalidOperationException("Empty shader body"); List descriptorRanges = new List(); int constantBuffersCount = 0; @@ -134,7 +129,7 @@ namespace ComputeSharp.Shaders.Translation descriptorRanges.Add(new DescriptorRange(DescriptorRangeType.ConstantBufferView, 1, constantBuffersCount++)); // Inspect the captured fields - foreach (FieldInfo fieldInfo in ShaderFields) + foreach (FieldInfo fieldInfo in shaderFields) { Type fieldType = fieldInfo.FieldType; string fieldName = fieldInfo.Name;