From 8a156e76bbaa4b7a2d6674d97341e5867452ea05 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 18 Aug 2019 12:48:08 +0200 Subject: [PATCH] Added type and name properties to readable member class --- .../Translation/Models/ReadableMember.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs b/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs index 46468367..4210d242 100644 --- a/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs +++ b/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs @@ -30,6 +30,25 @@ namespace ComputeSharp.Shaders.Translation.Models Property = property; } + /// + /// Gets the of the wrapped member for the current instance + /// + public Type MemberType + { + get + { + if (Field != null) return Field.FieldType; + if (Property != null) return Property.PropertyType; + + throw new InvalidOperationException("Field and property can't both be null at the same time"); + } + } + + /// + /// Gets the name of the wrapped member for the current instance + /// + public string Name => (Field?.Name ?? Property?.Name) ?? throw new InvalidOperationException("Field and property can't both be null at the same time"); + /// /// Returns the value of the wrapped member for the current instance ///