From 45b991ff59bea657a2689e0bfc1470996976ce72 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 17 Aug 2019 13:00:32 +0200 Subject: [PATCH] Code refactoring --- src/ComputeSharp.Shaders/Translation/ShaderLoader.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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;