This repository was archived by the owner on Jun 28, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +38
-12
lines changed
src/Avalonia.NameGenerator/Generator Expand file tree Collapse file tree 3 files changed +38
-12
lines changed Original file line number Diff line number Diff line change 1+ using System . Linq ;
2+ using XamlX . TypeSystem ;
3+
4+ namespace Avalonia . NameGenerator . Generator ;
5+
6+ internal static class ResolverExtensions
7+ {
8+ public static bool IsAvaloniaControl ( this IXamlType clrType )
9+ {
10+ return clrType . HasControlBaseType ( ) || clrType . HasIControlInterface ( ) ;
11+ }
12+
13+ private static bool HasControlBaseType ( this IXamlType clrType )
14+ {
15+ // Check for the base type since IControl interface is removed.
16+ // https://github.com/AvaloniaUI/Avalonia/pull/9553
17+ if ( clrType . FullName == "Avalonia.Controls.Control" )
18+ return true ;
19+
20+ if ( clrType . BaseType != null )
21+ return IsAvaloniaControl ( clrType . BaseType ) ;
22+
23+ return false ;
24+ }
25+
26+ private static bool HasIControlInterface ( this IXamlType clrType )
27+ {
28+ return clrType
29+ . Interfaces
30+ . Any ( abstraction => abstraction . IsInterface &&
31+ abstraction . FullName == "Avalonia.Controls.IControl" ) ;
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -31,12 +31,8 @@ IXamlAstNode IXamlAstVisitor.Visit(IXamlAstNode node)
3131 return node ;
3232
3333 var clrType = objectNode . Type . GetClrType ( ) ;
34- var isAvaloniaControl = clrType
35- . Interfaces
36- . Any ( abstraction => abstraction . IsInterface &&
37- abstraction . FullName == "Avalonia.Controls.IControl" ) ;
3834
39- if ( ! isAvaloniaControl )
35+ if ( ! clrType . IsAvaloniaControl ( ) )
4036 return node ;
4137
4238 foreach ( var child in objectNode . Children )
Original file line number Diff line number Diff line change 66using XamlX ;
77using XamlX . Ast ;
88using XamlX . Parsers ;
9+ using XamlX . TypeSystem ;
910
1011namespace Avalonia . NameGenerator . Generator ;
1112
@@ -55,19 +56,15 @@ public ResolvedView ResolveView(string xaml)
5556 return null ;
5657 }
5758 }
58-
59+
5960 IXamlAstNode IXamlAstVisitor . Visit ( IXamlAstNode node )
6061 {
6162 if ( node is not XamlAstObjectNode objectNode )
6263 return node ;
6364
6465 var clrType = objectNode . Type . GetClrType ( ) ;
65- var isAvaloniaControl = clrType
66- . Interfaces
67- . Any ( abstraction => abstraction . IsInterface &&
68- abstraction . FullName == "Avalonia.Controls.IControl" ) ;
6966
70- if ( ! isAvaloniaControl )
67+ if ( ! clrType . IsAvaloniaControl ( ) )
7168 return node ;
7269
7370 foreach ( var child in objectNode . Children )
@@ -102,4 +99,4 @@ IXamlAstNode IXamlAstVisitor.Visit(IXamlAstNode node)
10299 void IXamlAstVisitor . Push ( IXamlAstNode node ) { }
103100
104101 void IXamlAstVisitor . Pop ( ) { }
105- }
102+ }
You can’t perform that action at this time.
0 commit comments