Skip to content

Commit 1d4fdf1

Browse files
committed
Fixed remaining unit tests
1 parent 422fa6c commit 1d4fdf1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Microsoft.Toolkit.Uwp.UI/Extensions/Tree/LogicalTree.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -566,24 +566,25 @@ public static IEnumerable<FrameworkElement> FindParents(this FrameworkElement el
566566
/// <returns>The retrieved content control, or <see langword="null"/> if not available.</returns>
567567
public static UIElement? TryGetContentControl(this FrameworkElement element)
568568
{
569-
Type? type = element.GetType();
569+
Type type = element.GetType();
570+
TypeInfo typeInfo = type.GetTypeInfo();
570571

571-
while (type is not null)
572+
while (typeInfo is not null)
572573
{
573574
// We need to manually explore the custom attributes this way as the target one
574-
// one is not returned by any of the other available GetCustomAttribute<T> APIs.
575-
foreach (CustomAttributeData attribute in type.CustomAttributes)
575+
// is not returned by any of the other available GetCustomAttribute<T> APIs.
576+
foreach (CustomAttributeData attribute in typeInfo.CustomAttributes)
576577
{
577578
if (attribute.AttributeType == typeof(ContentPropertyAttribute))
578579
{
579580
string propertyName = (string)attribute.NamedArguments[0].TypedValue.Value;
580-
PropertyInfo propertyInfo = type.GetProperty(propertyName);
581+
PropertyInfo? propertyInfo = type.GetProperty(propertyName);
581582

582-
return propertyInfo.GetValue(element) as UIElement;
583+
return propertyInfo?.GetValue(element) as UIElement;
583584
}
584585
}
585586

586-
type = type.BaseType;
587+
typeInfo = typeInfo.BaseType.GetTypeInfo();
587588
}
588589

589590
return null;

0 commit comments

Comments
 (0)