From 19c86440587fcb7a6c16ef107d330ec70dd9faa7 Mon Sep 17 00:00:00 2001 From: Xianbing Teng Date: Tue, 22 Feb 2022 16:04:00 +0800 Subject: [PATCH] [NUI] Fix GetProperty ambiguousmatch exception --- .../src/internal/EXaml/Operation/GatherProperty.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherProperty.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherProperty.cs index 039e2e1..215e782 100755 --- a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherProperty.cs +++ b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherProperty.cs @@ -38,7 +38,23 @@ namespace Tizen.NUI.EXaml public void Do() { var type = globalDataList.GatheredTypes[typeIndex]; - globalDataList.GatheredProperties.Add(type.GetProperty(propertyName)); + PropertyInfo propertyInfo = null; + try + { + propertyInfo = type.GetProperty(propertyName); + } +#pragma warning disable CA1031 // Do not catch general exception types + catch (Exception) +#pragma warning restore CA1031 // Do not catch general exception types + { + propertyInfo = type.GetProperty(propertyName, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance); + } + + if (null == propertyInfo) + { + throw new Exception($"Can't find property {propertyName} from type {type.FullName}"); + } + globalDataList.GatheredProperties.Add(propertyInfo); } private int typeIndex; -- 2.7.4