From c78f51fad10a69707dd75445ab68c92928170c7a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 20 Aug 2019 15:27:04 +0200 Subject: [PATCH] Added DeclaringType property to ReadableMember type --- .../Translation/Models/ReadableMember.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs b/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs index 09507d2e..b0ba6344 100644 --- a/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs +++ b/src/ComputeSharp.Shaders/Translation/Models/ReadableMember.cs @@ -30,6 +30,20 @@ namespace ComputeSharp.Shaders.Translation.Models Property = property; } + /// + /// Gets the where the current member is declared in + /// + public Type DeclaringType + { + get + { + if (Field != null) return Field.DeclaringType; + if (Property != null) return Property.DeclaringType; + + throw new InvalidOperationException("Field and property can't both be null at the same time"); + } + } + /// /// Gets the of the wrapped member for the current instance ///