From 750d5dab8d6df24479b54ec56ab263fb491ab9cd Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 22 Jan 2019 14:39:29 +0100 Subject: [PATCH] Fix bound types not considering interfaces inheriting from other interfaces --- .../BoundTypes/UserDataBoundTypeDefinition.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs b/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs index f445a43..826bb2c 100644 --- a/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs +++ b/Upsilon/BoundTypes/UserDataBoundTypeDefinition.cs @@ -36,7 +36,7 @@ namespace Upsilon.BoundTypes Properties = new Dictionary(), Name = name }; - var fields = backingType.GetFields().Select(x => new UserDataBoundProperty() + var fields = backingType.GetFields(BindingFlags.Public | BindingFlags.Instance).Select(x => new UserDataBoundProperty() { Name = x.Name, ActualType = x.FieldType.Name, @@ -46,7 +46,19 @@ namespace Upsilon.BoundTypes { obj.Properties.Add(f.Name.ToLowerInvariant(), f); } - var properties = backingType.GetProperties().Select(x => new UserDataBoundProperty() + + PropertyInfo[] realProperties; + if (backingType.IsInterface) + { + realProperties = new[]{backingType} + .Concat(backingType.GetInterfaces()) + .SelectMany(x => x.GetProperties(BindingFlags.Public | BindingFlags.Instance)).ToArray(); + } + else + { + realProperties = backingType.GetProperties(BindingFlags.Public | BindingFlags.Instance); + } + var properties = realProperties.Select(x => new UserDataBoundProperty() { Name = x.Name, ActualType = x.PropertyType.Name, @@ -57,7 +69,7 @@ namespace Upsilon.BoundTypes obj.Properties.Add(f.Name.ToLowerInvariant(), f); } var methods = new Dictionary(); - var backingMethods = backingType.GetMethods(); + var backingMethods = backingType.GetMethods(BindingFlags.Public | BindingFlags.Instance); foreach (var backingMethod in backingMethods) { if (backingMethod.IsSpecialName)