From: Xianbing Teng Date: Tue, 22 Feb 2022 08:04:00 +0000 (+0800) Subject: [NUI] Fix GetProperty ambiguousmatch exception X-Git-Tag: accepted/tizen/unified/20231205.024657~1155 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=19c86440587fcb7a6c16ef107d330ec70dd9faa7;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Fix GetProperty ambiguousmatch exception --- 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;